I am trying to implement a chatbot which uses WebSocket to connect from the user’s browser to the Oracle Digital Assistant REST endpoint. I am getting an error (seen in the browsers developer tools console):
WebSocket
connection to
wss://oda-2098097sdjhjk476242-jnajb-da2.data.digitalassistant.oci.oraclecloud.com/botsui//xxxxxx
failed
.
In order to determine why it is failing to connect, I tried testing a WebSocket request using postman. The result said:
Could not connect to
wss://oda-2adb07ccffc34e858dd09086cfb194ec-da2.data.digitalassistant.oci.oraclecloud.com/botsui//chat/v1/chats/sockets/websdk?channelId=2f89f2bc-286f-42eb-bc06-4e53fe7da92d&userId=6d99d8e9-
Error:
Unexpected server response: 200
Obviously 200 is usually the desired HTTP Response Status Code that we usually want, but Postman is reporting this as an Error and saying that it is not able to connect. I think that the desired response code for a wss handshake is 101 (Switching Protocols).
So, what does a 200 return code mean during a wss handshake/upgrade request?
Request URL:
Oracle Digital Assistant
Request Method: GET
Status Code: 200 OK
Request Headers
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: Io/rCxtPBawusOgTXNsQQQ==
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Host:
oda-2adxxxxxxxx6cfb194ec-da2.data.digitalassistant.oci.oraclecloud.com
Response Headers
Date: Tue, 16 Apr 2024 18:31:49 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Request-ID: aa1b4c1eb7a3f3ead27a3ccaf88a6a20
Strict-Transport-Security: max-age=31536000; includeSubDomains
I am running Postman in my browser (MS-EDGE) on Windows 10 using the Desktop Agent
Hey
@mmyers44
, welcome to the community!
As per the
RFC
(and as you rightly mentioned), if a client wants to connect to a server over WebSocket, the handshake response should have a 101 (Switching Protocols) status code, which informs the client that the server has agreed to upgrade the connection.
If the server responds with any other status code, the handshake is considered incomplete and continues to be treated as a regular HTTP connection.
In your case, a 200 OK might mean that the endpoint you are trying to connect to only accepts HTTP connection, and there might be a different URL path (or entirely a different URL) that serves over WebSocket.
Lastly, I am not familiar with Oracle Digital Assistant, but looking at the URL, it seems that it serves the chatbot UI, not the one that directly connects you with the chatbot server.