Can UWP apps communicate via network?
I tried running the Sockets Example from MSDN. The communication works, but only within the same app. If I try to connect to the socket from another app, the socket does not seem to receive any data.
I set the capabilities properly (Internet (Client & Server), Internet (Client) and Private Networks (Client & Server)).
I tried copying the same client code to another UWP app, but it fails to communicate to the server app (however, it hangs, the connection is not refused if the server app is running). I tried communicating with the socket from a .NET Console application. This also failed.
I viewed the related post (Connecting two local uwp Apps on same machine) and made sure not to run the server on localhost, but rather to run it on a local address as suggested in How do I find the local IP address on a Win 10 UWP project.
However, this did not help. The socket is only reachable from within the server UWP app.
When I run netstat -a, I can see the app listening on 0.0.0.0:1337. I also tried on 127.0.0.1, localhost and my LAN IP. I tried disabling Windows Firewall, but it did not help.
Any suggestions?
Evidently, the answer is no. Packets are prevented from reaching the socket if the UWP server is on the same machine as the client.
Socket Communication on UWP(Universial Windows Platporm)
Related
I'm developing an UWP app which needs to be the server for a win32 client application, which is not to be changed if possible. Now the problem is I can connect to my uwp server application if I connect to the hostname or IP address of my computer. In contrast if I use localhost or 127.0.0.1 I can't get a connection.
I'm running this command constantly to enable the connection without running it, it doesn't work at all. "CheckNetIsolation.exe LoopbackExempt -is -n=Packagename"
I also executed some tests, and found out that on the computer under company IT, it only works when using the IP address. Therefore with the identical setup on a computer which is not under the companies IT, it works as expected.
So I expect there's a problem with the way my machine is configured.
We have an proxy for all outgoing connections. Another thing when I use a win32 server and client I have no problem to connect to localhost, so it seems that my machines dns configuration is in general right.
Do you have any ideas how to torubleshoot this, or what I can try to find out where my connection attempt is going. Maybe the UWP application is trying to connect over the proxy?
I created a C# console app web socket. It works and handles everything on my local machine, but now I have uploaded it on a real server so I can connect to it anytime.
But when I connect to the server endpoint, no connection is being made. I get this error:
WebSocket connection to 'ws:// ... :8083/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
I have opened the port using:
netsh firewall add portopening TCP 8083 "NetBIOS TCP Port 8083"
and I've also tested to see if it's listening, and it is:
netstat -na | find "8083"
I repeat that the console app web socket was working on my local machine, but not working on the real server.
Any thoughts on this? Thank you!
Having some trouble with websocket-connection within the local network.
Scenario:
For my laptop (Win7) I've written a service which opens a websocket-server to port 2014. Because websockets aren't enabled by default for windows 7 I'm using the supersocket library ( http://www.supersocket.net/ ).
For the Client I've written a android app with sencha touch and Phonegap. To enable websocket- support for android devices with version lower 4.4 I've integrated the phonegap websocket- pugin.
The reason is to open a websocket-connection between the android device and the laptop to control the laptop by the android app. Both devices are members of the same local network.
The problem:
After installing both applications (windows service and android app) I've tried to connect my android device with the service from the laptop. First step is to open the connection on the client:
var connection = new WebSocket('ws://192.168.178.21:2014');
But in the event-logs of my windows service there is no successful connection logged.
After that I opened the browser of my laptop and tested the same code - successful. Client and Server could communicate with each other.
So I've tested the websocket-support on my android device: changed the websocket-url to
var connection = new WebSocket('ws://echo.websocket.org');
and could connect to the server -> Android websockets are okay.
Third step was to disable my firewall and check the connection with Wireshark:
Screenshot:http://www.directupload.net/file/d/3710/y9t79npy_png.htm
192.168.178.21 -> Laptop IP
192.168.178.23 -> Android device IP
So it seems that the packets reach my laptop but not the service. Additional tried to use the secure wss:// protocol - no victory.
Don't have any ideas anymore. Would be a pleasure to get some help :)
So it seems that the packets reach my laptop but not the service.
Could it be that the server is binding to a specific IP address or hostname? Often servers will implicitly bind to all interfaces, such as 0.0.0.0, but sometimes they bind to one specific interface. If that happens, then you need to connect to that same interface.
You said your client is connecting to ws://192.168.178.21:2014, but could it be that the server is binding to 127.0.0.1 or localhost or your hostname, and therefore doesn't see the request? That could explain why the laptop received the request, but not your service.
Then again, you said you tried it from your local browser, and it worked. Did you use the same IP address, or did you use 127.0.0.1 or localhost? Assuming you used the same IP address, 192.168.178.21, then that would indicate it's not the bind issue I described.
Sorry, that's all I can think of at the moment.
After some time i´ve found the solution:
Had to add the firewall rule to the public firewall options.
Thanks for your help:)
I have a server program and a client program. I built it based from the appliation from this tutorial. The thing is, it works (connects successfully and communicates) when I run both the program on the same computer. But when I tried running the client app in a different computer from where the server runs and connect it to the server app, this exception happens:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 169.254.212.31:1986
I made sure that the client app will connect to the IP Address that the Server App listens to. I am running my application in a LAN. What should I do to resolve this problem?
UPDATE:
I'm sorry, forgot to put the link of the tutorial I was talking about. Here it is.
Solved the problem by opening a port (in my case, Port 1986).
I followed this guide:
How to open a port in windows 7 firewall
How do I redirect an incomming request on port xxx to localhost:yyy on windows 7?
Development Server (vs 2008) only allow access from localhost which isnt good enough. I need to test my app from various computers.
Thanks for the suggestions guys, although I found the answer myself.
I downloaded Microsoft SOAP Toolkit version 3 and started MSSoapT, created a formatted trace listening on port 8080, forwarding to host: 127.0.0.1 port: 3804. My problem was I used "localhost" and not "127.0.0.1".
Now every request made to my development machine from other computers through port 8080 will be redirected to port 3804 where ASP.NET Development Server is statically set to listen when debugging VS.NET webapps.
On the command prompt.
$> netsh
$> interface portproxy
$> add v4tov4 listenport=xxx connectaddress=127.0.0.1 connectport=yyy protocol=tcp
See: http://technet.microsoft.com/en-us/library/cc776297%28WS.10%29.aspx#BKMK_1
If this really is for some testing, you could create a server which listens on a port, and when it receives an incoming connection spawns a thread that opens a connection to the actual local server, and afterward just waits for data to come in either end and shuffle it along to the other end. If either socket closes, the worker thread would terminate. This is obviously not a scalable solution, but for testing it should easily do the trick.
Not really sure what you are looking for. However port forwarding will be relevant when you have a router in place and you need to explicitly forward a request on a specific router port to a specific IP and port on a LAN computer. If you want to access the web server from other LAN computers on the same network then http://ip-address should just work fine. Also make sure that your web server is listening on the LAN IP and is not just bound to localhost.
I'm using windows 7 64 bit and couldn't get the Microsoft SOAP Toolkit to work on my machine for port forwarding and didn't like the free port forwarding software I found out there so I just changed my VS 2010 web app to use local iis, I know this doesn't help people running 2008 but it works if you have 2010... Here's a screen shot of my change: I'm doing this for testing on the iPad...