Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSS Not working for some sites. #9

Closed
bastienvans opened this issue May 17, 2019 · 18 comments
Closed

WSS Not working for some sites. #9

bastienvans opened this issue May 17, 2019 · 18 comments
Assignees
Labels
bug Something isn't working

Comments

@bastienvans
Copy link

bastienvans commented May 17, 2019

Using your example, I can connect to wss://echo.websocket.org but not wss://ws-feed.pro.coinbase.com, nor wss://api.bitfinex.com/ws/2.

I've tried with fingerprint and with client.setInsecure(), no luck.

Some logs:

14:19:08.149 -> connect ws...
14:19:08.149 -> [hostByName] request IP for: api.bitfinex.com
14:19:08.184 -> pm open,type:2 0
14:19:08.184 -> [hostByName] Host: api.bitfinex.com IP: 104.16.171.181
14:19:08.252 -> :ref 1
14:19:08.287 -> BSSL:_connectSSL: start connection
14:19:08.321 -> :wr 221 0
14:19:08.321 -> :wrc 221 221 0
14:19:08.356 -> :ack 221
14:19:08.391 -> :rn 536
.......................................
14:19:09.598 -> :rdi 32, 32
14:19:09.598 -> :c0 32, 43
14:19:09.632 -> BSSL:Connected!
14:19:09.632 -> :wr 180 0
14:19:09.632 -> :wrc 180 180 0
14:19:09.737 -> :ack 180
14:19:09.737 -> BSSL:read: failed
14:19:09.737 -> BSSL:read: failed
14:19:09.771 -> BSSL:read: failed
14:19:09.805 -> BSSL:read: failed
14:19:09.805 -> BSSL:read: failed
14:19:09.839 -> BSSL:read: failed
14:19:09.839 -> BSSL:read: failed
14:19:09.874 -> BSSL:read: failed
14:19:09.874 -> BSSL:read: failed
14:19:09.908 -> BSSL:read: failed
14:19:09.908 -> BSSL:read: failed
14:19:09.943 -> BSSL:read: failed
14:19:09.977 -> BSSL:read: failed
14:19:09.977 -> BSSL:read: failed
14:19:10.011 -> BSSL:read: failed
14:19:10.011 -> BSSL:read: failed
14:19:10.046 -> :rn 536
14:19:10.046 -> :rch 536, 173
14:19:10.080 -> :rch 709, 125

If I try connecting to the unsecured ones (ws://api.bitfinex.com/ws/2)

14:23:46.080 -> connect ws...
14:23:46.080 -> [hostByName] request IP for: api.bitfinex.com
14:23:46.115 -> pm open,type:2 0
14:23:46.149 -> [hostByName] Host: api.bitfinex.com IP: 104.16.175.181
14:23:46.183 -> :ref 1
14:23:46.218 -> :wr 159 0
14:23:46.218 -> :wrc 159 159 0
14:23:46.288 -> :ack 159
14:23:46.288 -> :rn 288
14:23:46.288 -> :wr 2 0
14:23:46.288 -> :wrc 2 2 0
14:23:46.323 -> :wr 2 0
14:23:46.323 -> :wrc 2 2 0
14:23:46.358 -> :ack 2
14:23:46.358 -> :rch 288, 332
14:23:46.358 -> :rcl
14:23:46.358 -> :abort
14:23:46.392 -> Connnection Closed

Any ideas?

Thanks a lot

@gilmaimon
Copy link
Owner

Thank you for the report, I was able to reproduce this bug on my side and can confirm it is a bug.
I will look into it and will post here any updates I'll have.

@gilmaimon gilmaimon self-assigned this May 17, 2019
@gilmaimon gilmaimon added the bug Something isn't working label May 17, 2019
@johneakin
Copy link

I am also looking this to work for
wss://ws-feed.gdax.com

@bastienvans
Copy link
Author

I am also looking this to work for
wss://ws-feed.gdax.com

Their API URL has changed to ws-feed.pro.coinbase.com.

@bastienvans
Copy link
Author

Thank you for the report, I was able to reproduce this bug on my side and can confirm it is a bug.
I will look into it and will post here any updates I'll have.

Thanks!

I got it to work using another code posted on github. I ended up using WiFiClientSecureBearSSL.

@johneakin
Copy link

johneakin commented May 18, 2019

Is that now working with a socket or just an HTTPS request?
Can you include the source code for connecting to wss://ws-feed.pro.coinbase.com

@gilmaimon
Copy link
Owner

Thank you for the report guys. I've fount at least one bug that had to do with the parsing of the server's response. For some reason, wss://ws-feed.pro.coinbase.com returns one header which is a-bit diffrent than standard.

The problem is still not fully solved, as I am able to make a connection with wss://ws-feed.pro.coinbase.com without it closing the connection immidiatly. Yet, the connection does not seem to be active (I was unable to receive any response from the server).

Communicating with wss://api.bitfinex.com/ws/2 works fine after the patch. By the end of the day there will be a patch live, hopefully it will solve both issues.

@gilmaimon
Copy link
Owner

Hi guys @bastienvans @johneakin

I believe the issue is now solved complely. Patch 0.4.1 is live!
It is available now via the release page and will be soon available for update via the Arduino IDE.

Thank you for reporting the issue and providing usefull information and logs. Please verify it is working for you properly.

@johneakin
Copy link

johneakin commented May 18, 2019

Thanks
I'll give it a try and report back

When you say completely solved, Do you mean also working for: wss://ws-feed.pro.coinbase.com
?

@johneakin
Copy link

johneakin commented May 18, 2019

wss://ws-feed.pro.coinbase.com is connecting and staying connected
but onMessageCallback doesn't appear to be getting called with new data which should be coming in regularly

@gilmaimon
Copy link
Owner

@johneakin Try adding a dummy send method and see if the you get the server's response. For me, adding send for "hello" in setup will return the message {"type":"error","message":"Malformed JSON","original":"hello"} immidiatly.
What kind of data you expect to get "regulary" from the socket? I've tried the connection on PC (with some downloaded websockets client) and the connection seems to disconnect after few seconds of inactivity.

@bastienvans
Copy link
Author

@johneakin Try adding a dummy send method and see if the you get the server's response. For me, adding send for "hello" in setup will return the message {"type":"error","message":"Malformed JSON","original":"hello"} immidiatly.
What kind of data you expect to get "regulary" from the socket? I've tried the connection on PC (with some downloaded websockets client) and the connection seems to disconnect after few seconds of inactivity.

Yeah, you have to keep pinging it to stay connected.

@johneakin
Copy link

My fault, I wasn't sending the subscribe json

client.connect("wss://ws-feed.pro.coinbase.com");
client.send("{"type": "subscribe","product_ids": ["BTC-USD"],"channels": ["ticker"]}");

After I send that I get the frequent price updates in the: onMessageCallback

@gilmaimon
Copy link
Owner

@johneakin Great! I'm glad it's working now.
@bastienvans Did it work for you aswell?

@johneakin
Copy link

Many thanks
Seems to be working great.

@gilmaimon
Copy link
Owner

Fantastic! Thank you guys for bringing up the issue.
Gil.

@imesut
Copy link

imesut commented Feb 23, 2020

Hello,

I see the same issue while working with wss://stream.toggl.com/ws link.

This link receives authentication token then decides to continue or disconnect. But in every attempt, it disconnects immediately before sending token.

The patch also didn't worked for me. Any suggestions?

@gilmaimon
Copy link
Owner

Hello,

I see the same issue while working with wss://stream.toggl.com/ws link.

This link receives authentication token then decides to continue or disconnect. But in every attempt, it disconnects immediately before sending token.

The patch also didn't worked for me. Any suggestions?

Hi,

Are you sure it's the same issue? Open a new issue and I will look into it.

Gil

@imesut
Copy link

imesut commented Feb 24, 2020

Hello,
I see the same issue while working with wss://stream.toggl.com/ws link.
This link receives authentication token then decides to continue or disconnect. But in every attempt, it disconnects immediately before sending token.
The patch also didn't worked for me. Any suggestions?

Hi,

Are you sure it's the same issue? Open a new issue and I will look into it.

Gil

Thanks, I've opened Issue 67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants