Does Wiced support websocket client to connect to such as - wss://host:port/path websocket server?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LeonH
Level 4
Level 4
Distributor - Arrow(GC)
100 sign-ins First solution authored 50 sign-ins

I need to use websocket client to connect wss://host:port/path server on Wiced 6.4

but it seems not support path in host, only support wss://host

Does Wiced not support it or I miss some setting in code?

0 Likes
1 Solution
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

I printed out the result from the website you provided , I think they are using a not very strict define in their server:

server_response[HTTP/1.1 101 Switching Protocols

connection: Upgrade

date: Wed, 25 Mar 2020 10:44:08 GMT

sec-websocket-accept: EjO5jaXGHWBZKexAABC12S28=

server: Cowboy

upgrade: websocket

we have a lot of case sensitive settings in the fields, please modify below to have a try:

I already have a success to visit the server by using websocket_client:

#define HTTP_UPGRADE_CASE_SENSITIVE_TOKEN                "Upgrade"

#define HTTP_UPGRADE_CASE_INSENSITIVE_TOKEN              "WEBSOCKET"

#define HTTP_CONNECTION_CASE_SENSITIVE_TOKEN             "connection: "

#define HTTP_CONNECTION_CASE_INSENSITIVE_TOKEN           "UPGRADE"

#define HTTP_WEBSOCKET_ACCEPT_CASE_SENSITIVE_TOKEN       "sec-websocket-accept: "

static const wiced_websocket_client_url_protocol_t websocket_header =

{

   .request_uri            = "/ws",

   .host                   = "edengardentool.com", // connection to hosts with an ip-address(like internal servers) will also work.

   //.host                   = "192.168.1.49",

   .origin                 = "https://edengardentool.com",

           //"https://edengardentool.com",

   //"123.207.136.134",

   .sec_websocket_protocol =  NULL,

};

View solution in original post

0 Likes
5 Replies
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

I just  have a test by using websocket server and client:

in server we can set to :

.url = "wws://192.168.2.3/" ,

or

  .url = "wws://192.168.2.3/chat"

client side is:

static const wiced_websocket_client_url_protocol_t websocket_header =

{

   .request_uri            = "/",

   .host                   = "192.168.2.3", // connection to hosts with an ip-address(like internal servers) will also work.

   //.host                   = "192.168.1.49",

   .origin                 = "172.16.61.228",

   .sec_websocket_protocol =  NULL,

};

or

static const wiced_websocket_client_url_protocol_t websocket_header =

{

   .request_uri            = "/chat",

   .host                   = "192.168.2.3", // connection to hosts with an ip-address(like internal servers) will also work.

   //.host                   = "192.168.1.49",

   .origin                 = "172.16.61.228",

   .sec_websocket_protocol =  NULL,

};

take this as a reference .

LeonH
Level 4
Level 4
Distributor - Arrow(GC)
100 sign-ins First solution authored 50 sign-ins

Hi Zhengbao,

if server is like "wss://192.168.2.3:8443/ws"

I use the setting as below, but still failed to connect.

#define WEBSOCKET_SECURE_SERVER_STD_PORT  (8443)

static const wiced_websocket_client_url_protocol_t websocket_header =

{

   .request_uri            = "/ws",

   .host                   = "192.168.2.3", // connection to hosts with an ip-address(like internal servers) will also work.

   //.host                   = "192.168.1.49",

   .origin                 = "172.16.61.228",

   .sec_websocket_protocol =  NULL,

};

0 Likes
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

I really need to have a study if wws can change the default port ,  so the default one is ok ?

I also have a test by using the open websocket test from internet, there has no option to let you change the port. 

Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

I printed out the result from the website you provided , I think they are using a not very strict define in their server:

server_response[HTTP/1.1 101 Switching Protocols

connection: Upgrade

date: Wed, 25 Mar 2020 10:44:08 GMT

sec-websocket-accept: EjO5jaXGHWBZKexAABC12S28=

server: Cowboy

upgrade: websocket

we have a lot of case sensitive settings in the fields, please modify below to have a try:

I already have a success to visit the server by using websocket_client:

#define HTTP_UPGRADE_CASE_SENSITIVE_TOKEN                "Upgrade"

#define HTTP_UPGRADE_CASE_INSENSITIVE_TOKEN              "WEBSOCKET"

#define HTTP_CONNECTION_CASE_SENSITIVE_TOKEN             "connection: "

#define HTTP_CONNECTION_CASE_INSENSITIVE_TOKEN           "UPGRADE"

#define HTTP_WEBSOCKET_ACCEPT_CASE_SENSITIVE_TOKEN       "sec-websocket-accept: "

static const wiced_websocket_client_url_protocol_t websocket_header =

{

   .request_uri            = "/ws",

   .host                   = "edengardentool.com", // connection to hosts with an ip-address(like internal servers) will also work.

   //.host                   = "192.168.1.49",

   .origin                 = "https://edengardentool.com",

           //"https://edengardentool.com",

   //"123.207.136.134",

   .sec_websocket_protocol =  NULL,

};

0 Likes
LeonH
Level 4
Level 4
Distributor - Arrow(GC)
100 sign-ins First solution authored 50 sign-ins

Hi ZhengbaoZ_96,

Yes, it is about case sensitive.

Now, I can connect to customer's server.

Thank you.

0 Likes