#1 2023-06-13 02:13:28

keinn
Member
Registered: 2014-10-20
Posts: 100

websocket client small bug

mormot.net.ws.client

1、line 308, THttpClientWebSockets.WebSocketsConnect

result := Open(aHost, aPort);

this code does NOT support WSS connection(443 port or other port with ssl),need some method to auto select is ws or wss

2、line 464,465 ,THttpClientWebSockets.WebSocketsUpgrade

      prot := HeaderGetValue('SEC-WEBSOCKET-PROTOCOL');
      result := 'Invalid HTTP Upgrade Header';
      if not (hfConnectionUpgrade in Http.HeaderFlags) or
         (Http.ContentLength > 0) or
         not PropNameEquals(Http.Upgrade, 'websocket') or
         not aProtocol.SetSubprotocol(prot) then
        exit;
      aProtocol.Name := prot;

most 3rd party ws server does NOT return SEC-WEBSOCKET-PROTOCOL header(aProtocol.SetSubprotocol(prot) =false), for more capability, we should not check this header, also ,this check has no use except setting the protocol name where we can define by hand.

Last edited by keinn (2023-06-13 02:15:54)

Offline

#2 2023-06-13 08:05:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: websocket client small bug

Please try

1. https://github.com/synopse/mORMot2/commit/cb17fcca

2. SetSubProtocol() allows to switch e.g. between synopse binary or synopse JSON content from the client side. So it is of use.
You can set aProtocol.Name to '' for such servers.

Offline

Board footer

Powered by FluxBB