[Libwebsockets] Connecting to websocket server which doesn't use http upgrade mechanism

Andy Green andy at warmcat.com
Thu Jan 23 16:04:12 CET 2020



On 1/23/20 2:55 PM, Lucas Stinchcombe wrote:
> I'm trying to connect to we websocket url which has the form`wss://...` 
> using the minimal-ws-client-echo. I have a working python example using 
> https://pypi.org/project/websocket_client/. I did some packet capture 
> and noticed that the python implementation (which I have working) 
> doesn't send http requests and seems to establish a websocket connection 
> directly.

I really doubt it... the site says

websocket-client supports only hybi-13.

Hybi was where the ws RFC was developed and used the upgrade method for 
a very long time.

If you're capturing packets and it's in a tls tunnel, I think you have 
mistaken looking at the encrypted traffic for there not being any http 
level action, in fact it's what the encrypted packets are doing at the 
start inside the encrypted tunnel.

> Is there anyway to do this with libwebsockets?

What you were imagining isn't "websockets", and is unlikely to be what 
is happening from your python thing either.

Right thing to do is build lws + the echo example with 
-DCMAKE_BUILD_TYPE=DEBUG and then use, eg, -d1151 to get very verbose 
logging coming and get a clue that way.

Logs on the server side will probably shed some light as well if you 
control that.

-Andy



More information about the Libwebsockets mailing list