Highlighted
Contributor.
Contributor.
676 views

Unable to complete websocket handshake: web_websocket_connect request returning error

Hi,

I am currently trying to do scripting for a Chatbot application hosted in Microsoft Azure which transmits data through a websocket.

However, i am getting an error in the web_websocket_connect request with the error message "The operation completed successfully". Please find furtherdetails below.

It would be really helpful if someone can take a look. Thanks 

Request:

web_websocket_connect("ID=0",
        "URI=<stream_Url>",

        "Origin=<azure_host_url>",
        "OnOpenCB=OnOpenCB0",
        "OnMessageCB=OnMessageCB0",
        "OnErrorCB=OnErrorCB0",
        "OnCloseCB=OnCloseCB0",
        LAST);

 

Error message:

Action.c(199): Connection Failed: uri=<streamURL>, connection handle=157765096 [MsgId: MMSG-26000]
Action.c(199): Calling Vuser script function "OnErrorCB0", specified via the "OnErrorCB" argument of "web_websocket_connect" in Action.c(199) [MsgId: MMSG-26419]
WebSocket ID = 0 error occured. Error message = The operation completed successfully.
Action.c(199): Returned (rc=0) from Vuser script function "OnErrorCB0", specified via the "OnErrorCB" argument of web_websocket_connect in Action.c(199) [MsgId: MMSG-26418]

0 Likes
6 Replies
Highlighted
Super Contributor.
Super Contributor.

Do you have any type of negotiation happening prior to this, and perhaps you need to pass down some unique connection id in the URI, that is returned from that?

    web_websocket_connect("ID=0", 
        "URI=<UriNameString>DisplayContent?id={ConnectionId}", 
        "Origin=<OriginNameString>", 
        "OnOpenCB=OnOpenCB0", 
        "OnMessageCB=OnMessageCB0", 
        "OnErrorCB=OnErrorCB0", 
        "OnCloseCB=OnCloseCB0", 
        LAST);

Have you had a look at the recording snapshot?  Is there anything in it, that is missing when replayed in this block?

Highlighted
Contributor.
Contributor.

There is an authentication done prior and we are passing the values in Stream URL. I do not have the authority to share the URL. But please find below, the details including the hearders passed in the request.

web_remove_auto_header("Referer",LAST);
web_remove_auto_header("Accept-Encoding",LAST);
web_remove_auto_header("Accept-Language",LAST);
web_remove_auto_header("Accept",LAST);
web_remove_auto_header("Connection",LAST);
web_remove_auto_header("Host",LAST);
web_revert_auto_header("X-P2P-PeerDist");
web_revert_auto_header("X-P2P-PeerDistEx");

web_add_header("Accept-Encoding","gzip, deflate, br");
web_add_header("Accept-Language","en-US,en;q=0.9");
web_add_header("Cache-Control","no-cache");
web_add_header("Connection","Upgrade");
web_add_header("Pragma","no-cache");
web_add_header("Sec-WebSocket-Extensions","permessage-deflate; client_max_window_bits");
web_add_header("Sec-WebSocket-Version","13");
web_add_header("Sec-WebSocket-Key","dGhlIHNhbXBsZSBub25jZQ==");
web_add_header("Upgrade","websocket");
web_add_header("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36");

web_websocket_connect("ID=0",
        "URI=wss://<bot_URI>/conversations/{conversation_Id}/stream?watermark=-&t={token_captured}",
        "Origin=<Azure_Origin_URL>",
        "OnOpenCB=OnOpenCB0",
        "OnMessageCB=OnMessageCB0",
        "OnErrorCB=OnErrorCB0",
        "OnCloseCB=OnCloseCB0",
        LAST);

0 Likes
Highlighted
Contributor.
Contributor.

I also tried to anlayse the error message "The operation completed successfully.", but couldnot get any solutions. I am able to connect to the websocket using other tools.

Action.c(204): Connection Failed: uri=ws://<bot_URI>/conversations/<conversation_Id>/stream?watermark=-&t=<token_captured>, connection handle=199595112 [MsgId: MMSG-26000]
Action.c(204): Calling Vuser script function "OnErrorCB0", specified via the "OnErrorCB" argument of "web_websocket_connect" in Action.c(204) [MsgId: MMSG-26419]
WebSocket ID = 0 error occured. Error message = The operation completed successfully.
Action.c(204): Returned (rc=0) from Vuser script function "OnErrorCB0", specified via the "OnErrorCB" argument of web_websocket_connect in Action.c(204) [MsgId: MMSG-26418]
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Just wondering if that key is dynamic and should change each time?

web_add_header("Sec-WebSocket-Key","dGhlIHNhbXBsZSBub25jZQ==");

 

Your web-socket connect looks 100%.

You could try using fiddler to create your script, and see if it pulls in anything different.  Sorry I'm not more help!

0 Likes
Highlighted
Contributor.
Contributor.

Hi Claire,
Thanks for the time spend on this 🙂 . The key is can be a random base 64 value, and the same sec-websocket-key will be used to create sec-websocket-accept value in response. I used the same value in another tool and received successful 101 message. For some strange reason, connection is going to error state with LoadRunner 😞
0 Likes
Highlighted
New Member..
New Member..

Hi!

 

I'm having the same issue. I tried to capture the request with Fiddler, comparing the request sent by the Browser, and by LoadRunner, and I noticed that LoadRunner is adding a "Connection: Keep-Alive" header, that is causing troubles due to the request already has a connection header ("Connection: Upgrade). I wasn't able to prevent LoadRunner to add that Keep-Alive header. I tried:

- Unchecking the Keep-Alive option in the recording options.

- Adding  web_disable_keep_alive();

- Adding  web_remove_auto_header("Connection", "", LAST);

- Adding  web_cleanup_auto_headers();

- Adding another Connection header via "web_add_header".

Nothing worked.

Were you able to bypass this issue?

Thanks in advance!

 

BR,

Carlos.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.