Thursday, 10 November 2022
  7 Replies
  1.4K Visits
  Subscribe
Hi,

I was trying to use the Websocket Client CLI to connect with Geckodriver / Firefox, but it seems that Geckodriver has an issue with connections from localhost. See here and here for more details.

This is what is shown in the client console --


{"event": "error", "description": "Error Decoding Header: Switching Protocols [HTTP/1.1 400 Bad Request]"}
{"event": "disconnected", "code": 0}


Here is the captured HTTP request and response --


Frame 435: 260 bytes on wire (2080 bits), 260 bytes captured (2080 bits) on interface \Device\NPF_Loopback, id 0
Null/Loopback
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 56835, Dst Port: 9222, Seq: 1, Ack: 1, Len: 216
Source Port: 56835
Destination Port: 9222
[Stream index: 5]
[Conversation completeness: Complete, WITH_DATA (31)]
[TCP Segment Len: 216]
Sequence Number: 1 (relative sequence number)
Sequence Number (raw): 2973920447
[Next Sequence Number: 217 (relative sequence number)]
Acknowledgment Number: 1 (relative ack number)
Acknowledgment number (raw): 555817769
0101 .... = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
Window: 8442
[Calculated window size: 2161152]
[Window size scaling factor: 256]
Checksum: 0xfffa [unverified]
[Checksum Status: Unverified]
Urgent Pointer: 0
[Timestamps]
[SEQ/ACK analysis]
TCP payload (216 bytes)
Hypertext Transfer Protocol
GET /session/afbb4b0c-aed8-45db-b16e-baba587e7369 HTTP/1.1\r\n
Host: 127.0.0.1:9222\r\n
Upgrade: websocket\r\n
Connection: Upgrade\r\n
Sec-WebSocket-Key: Fz/9gz4uVaJHZU8885/ryQ==\r\n
Origin: 127.0.0.1\r\n
Sec-WebSocket-Version: 13\r\n
\r\n
[Full request URI: http://127.0.0.1:9222/session/afbb4b0c-aed8-45db-b16e-baba587e7369]
[HTTP request 1/1]
[Response in frame: 457]



Frame 457: 195 bytes on wire (1560 bits), 195 bytes captured (1560 bits) on interface \Device\NPF_Loopback, id 0
Section number: 1
Interface id: 0 (\Device\NPF_Loopback)
Encapsulation type: NULL/Loopback (15)
Arrival Time: Nov 7, 2022 19:09:33.752941000 Central Standard Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1667869773.752941000 seconds
[Time delta from previous captured frame: 0.000023000 seconds]
[Time delta from previous displayed frame: 0.001845000 seconds]
[Time since reference or first frame: 18.164051000 seconds]
Frame Number: 457
Frame Length: 195 bytes (1560 bits)
Capture Length: 195 bytes (1560 bits)
[Frame is marked: True]
[Frame is ignored: False]
[Protocols in frame: null:ip:tcp:http:data-text-lines]
[Coloring Rule Name: HTTP]
[Coloring Rule String: http || tcp.port == 80 || http2]
Null/Loopback
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Total Length: 191
Identification: 0x2918 (10520)
010. .... = Flags: 0x2, Don't fragment
...0 0000 0000 0000 = Fragment Offset: 0
Time to Live: 128
Protocol: TCP (6)
Header Checksum: 0x0000 [validation disabled]
[Header checksum status: Unverified]
Source Address: 127.0.0.1
Destination Address: 127.0.0.1
Transmission Control Protocol, Src Port: 9222, Dst Port: 56835, Seq: 1, Ack: 217, Len: 151
Source Port: 9222
Destination Port: 56835
[Stream index: 5]
[Conversation completeness: Complete, WITH_DATA (31)]
[TCP Segment Len: 151]
Sequence Number: 1 (relative sequence number)
Sequence Number (raw): 555817769
[Next Sequence Number: 152 (relative sequence number)]
Acknowledgment Number: 217 (relative ack number)
Acknowledgment number (raw): 2973920663
0101 .... = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
Window: 8441
[Calculated window size: 2160896]
[Window size scaling factor: 256]
Checksum: 0x0b33 [unverified]
[Checksum Status: Unverified]
Urgent Pointer: 0
[Timestamps]
[SEQ/ACK analysis]
TCP payload (151 bytes)
Hypertext Transfer Protocol
HTTP/1.1 400 Bad Request\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 400 Bad Request\r\n]
Response Version: HTTP/1.1
Status Code: 400
[Status Code Description: Bad Request]
Response Phrase: Bad Request
Server: httpd.js\r\n
Content-Type: text/plain\r\n
Content-Length: 59\r\n
\r\n
[HTTP response 1/1]
[Time since request: 0.001871000 seconds]
[Request in frame: 435]
[Request URI: http://127.0.0.1:9222/session/afbb4b0c-aed8-45db-b16e-baba587e7369]
File Data: 59 bytes
Line-based text data: text/plain (1 lines)
The handshake request has incorrect Origin header 127.0.0.1


I've confirmed that the connection is allowed if the "Origin" details are omitted from the HTTP upgrade request. Is there any way to configure sgcWebSocketClient.exe to not include the origin in the HTTP request?

TIA, Dan
2 years ago
·
#1253
Hello,

The executable sgcWebsocketClient.exe doesn't allow to change the handshake parameters, but if you use "localhost" instead of "127.0.0.1" to connect to the server, it doesn't works? seems the problem is using the IP address instead of the DNS name. If you use "localhost", the origin parameter will set "localhost" as string value.

Kind Regards,
Sergio
2 years ago
·
#1254
Sergio,

I just tried it, but the result is the same. I guess I will have to move my testing to another browser and wait until they fix it in geckodriver.

Thanks for the quick reply,
Dan

P.S. Is there a way to register as forum user or is that for paying customers only?
2 years ago
·
#1257
Hi,

I am sorry but only users who have purchase are registered in forums.

Kind Regards,
Sergio
2 years ago
·
#1281
FYI, sgcWebSocketClient crashes with an access violation if you "close connection with code".


{"message":"close", "params":{"code": 1000}}
EAccessViolation: Access violation at address 0060F24D in module 'sgcWebSocketClient.exe'. Read of address 00000000
2 years ago
·
#1283
FYI, sgcWebSocketClient crashes with an access violation if you "close connection with code".



Hi,

I've tested with the client for Windows 64 and here works well. Which OS are you using? and which server are you connecitng?

websocket_client_console.png

Kind Regards,
Sergio
2 years ago
·
#1284
Sergio,

OS is W11. Winver shows Microsoft Windows Version 22H2 (0S Build 22621.819). In my testing, the crash can be replicated by simply issuing the close command without connecting to a server.

Dan
2 years ago
·
#1285
Hello,

Ok, this was the problem, if the client was not connected it was trying to access to an internal object not initialized. I've fixed it and will be available on next version. Thanks for the feedback.

Kind Regards,
Sergio
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf,pas,dfm,dpr,dproj,dpk
· Insert · Remove
  Upload Files (Maximum 10MB)