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:)
Related
apologies for weak English
Hello my friends
I have a problem that very confused me
Project description:
I created c# wpf project for server side and android studio app for client side. in wpf I coded socket communication codes also in android studio. main point is I connected my phone to pc by charger cable as modem to connect the internet. also use the phone for debugging android studio app. when I test the communication between my pc and phone established successfully . it connects very good on android virtual device manager too . but when my friend install client app on his phone , connection is not established and my ip (192.168.xxx.xxx) is not accessible for client. I tried by my public ip founded from whatismyip.com but I don't socceeded
thanks in advance
special thanks for you and other friends
For safety reasons your modem is blocking request that come from the outside of your local network. You must setup a NAT/PAT on your modem to allow external request to be treated. There is tutorial on internet depending on your modem.
Hope that will help you.
Have nice day !
your private IP "192.168.xxx.xxx" is not routed over internet, you have to use your public IP provided by your ISP provider(NAT), if you are using ADSL router, log in to it IN ORDER TO find your public IP, then do port forwarding to your local IP address,and enable dynamic DNS, then you can access your private IP using public IP from anywhere over internet
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?
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)
I've published an Android app which communicates with a C# server app via UDP. I've implemented an "Auto Connect" feature which does broadcasting and receives an answer from the server. Once an answer received by phone, the phone app holds the sender IP and sends subsequent messages to this IP directly. Also there is a Manual Connect feature which sends data to the IP address the user enters (which is the local IP of the PC running the server app).
So, everything works great for lots of users but some users reported me that when they use manual connect, it never connects; when they use auto connect, the server gets the broadcast message (seems connected) and the phone receives the answer but afterwards none of the (direct) messages will be received by the server app. The common point of these users is that their PCs are connected to the WiFi router by wire and their phones are connected by wireless. I've tried the same thing on my network but again it works for me without any problem.
May it be because of having multiple network interfaces (both LAN and WLAN)? I've been searching net for 1 week but no success.
What should I do? Please help.
Thanks in advance.
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...