简体   繁体   中英

websocket can´t reach local network client service

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:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM