[Libwebsockets] Unable to connect to the server with Android

Stefano Mora stefano.mora at newdep.com
Tue Apr 16 16:52:16 CEST 2019


Hello,
I developed a ws server based on minimal sample: it is running on a Linux board.
When I connect with browsers everything is OK.
Now I'd like to connect with Android app and I'm using org.java-websocket:Java-WebSocket library.

When I connect the app to the server the onOpen callback is fired with the 101 code and 'Switching Protocols' as message.
The server does not enter in the ESTABLISHED phase and nothing else happen.

If I connect to other server (ex: echo.websocket.org) I'm able to send and receive strings.

I grabbed the data with Wireshark and this is the high-level info:

No.     Time           Source                Destination           Protocol Length Info
      1 0.000000       192.168.5.128         192.168.5.169         TCP      74     55631 → 7681 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 SACK_PERM=1 TSval=12225534 TSecr=0 WS=128
      2 0.000800       192.168.5.169         192.168.5.128         TCP      74     7681 → 55631 [SYN, ACK] Seq=0 Ack=1 Win=28960 Len=0 MSS=1460 SACK_PERM=1 TSval=2376790693 TSecr=12225534 WS=128
      3 0.002166       192.168.5.128         192.168.5.169         TCP      66     55631 → 7681 [ACK] Seq=1 Ack=1 Win=87680 Len=0 TSval=12225534 TSecr=2376790693
      4 0.012473       192.168.5.128         192.168.5.169         HTTP     223    GET / HTTP/1.1 
      5 0.013232       192.168.5.169         192.168.5.128         TCP      66     7681 → 55631 [ACK] Seq=1 Ack=158 Win=30080 Len=0 TSval=2376790705 TSecr=12225535
      6 0.014580       192.168.5.169         192.168.5.128         HTTP     196    HTTP/1.1 101 Switching Protocols 
      7 0.016257       192.168.5.128         192.168.5.169         TCP      66     55631 → 7681 [ACK] Seq=158 Ack=130 Win=88704 Len=0 TSval=12225536 TSecr=2376790706

This is a send() to the server:

      8 0.033029       192.168.5.128         192.168.5.169         WebSocket 99     WebSocket Text [FIN] [MASKED]
      9 0.074275       192.168.5.169         192.168.5.128         TCP      66     7681 → 55631 [ACK] Seq=130 Ack=191 Win=30080 Len=0 TSval=2376790766 TSecr=12225537

Any clue?
---
Stefano Mora




More information about the Libwebsockets mailing list