Skip to content

Cannot connect to WebSocket Server on local network (via wifi + no internet) if mobile data is on (with internet). #814

@robinchew

Description

@robinchew

Describe the bug

On my Android phone I have both wifi and mobile data on. But wifi has NO internet and mobile data has internet. My Android app uses Java-WebSocket to connect to the websocket server via IP (eg. 192.168.1.3) but times out. But if mobile data is turned off, then it will work.

To Reproduce
Steps to reproduce the behavior:

  1. Have a WebSocket server (eg. with IP 192.168.1.3) on your local area network.
  2. Your LAN has no internet
  3. On your Android phone, switch on Wifi to connect to the LAN with no internet.
  4. On your Android phone, switch on Mobile data so you do have internet.
  5. Run Android app that runs code that connects to the WebSocket Server, eg:
MyWebSocketClient(URI("ws://192.168.1.3:8888/websocket-handler/"))

Example application to reproduce the issue
Do I really need to?

Expected behavior
It should just work. If not, then how do you explicitly tell the WebSocketClient to connect to the Wifi network instead of the Mobile network?

Workaround
Switch off mobile data.

Debug log

W/System.err: an error occurred: java.net.ConnectException: failed to connect to /192.168.1.3 (port 8888) from /:: (port 46537): connect failed: ETIMEDOUT (Connection timed out)
I/System.out: closed with exit code -1 additional info: failed to connect to /192.168.1.3 (port 8888) from /:: (port 46537): connect failed: ETIMEDOUT (Connection timed out)

Environment(please complete the following information):

  • Version used: 1.3.9
  • Java version: 1.7 or 1.8
  • Operating System and version: ArchLinux
  • Endpoint Name and version:
  • Link to your project:

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions