Message too long?

I sat down tonight to use the level2 websocket and it appears now the message is too long to read in iOS. I’ve tried the known ways to increase the client’s ability to read the socket but no luck. Other websockets like market_trades work fine and the level2 worked fine earlier… HELP!

Hi @coinsensei! Thank you for using Advanced Trade API. We will surely help you with this. Can you please share more details related to this issue? A screenshot would be helpful too.

Sure, I’ve attached a screen shot. Basically some clients will be capped to how much data they can process. When the order book is too big, since the snapshot is returned first, it is too big to receive, not parse, receive. I checked ETH-USD last night and it worked and it does not this morning. BTC-USD hasn’t worked since yesterday morning when activity was high. I’m guessing there were less orders due to the volatility. I’m using straight websockets in iOS and they are set to receive the max amount of data. Other pairs like SOL, DOGE work every time. And other channels work fine too, it’s just the level2 channel on the advanced trade api. I tried going over to pro, even though it’s getting depreciated and it doesn’t authenticate in the same way for who knows why. Thoughts? How can we page the data? Or set a more standard size limit. I’m guessing anyone on a mobile platform using the level2 channel will encounter this issue. Maybe two consecutive snapshots? Then send the updates?

Is not this problem with your client?

Quick search in google:

If that is correct documentation then based on your screenshot your current limit is only 1 MB. Are you sure it can not be increased?

EDIT: Message could have smaller size if it was not too verbose.

That is the upcoming new NW frame work and it is in beta. I’m using standard url session and session task manager and I’ve set the settings to the max.

Have you verified that maximum limit changes? For example, set limit less than 1mb and check if error message now includes your set limit and not exceeds maximum message size 1,048,576. If that does not change you are not changing correct limit.

Actually I was setting the maximum connections because there is no way to set the maximum size in a url session. I left the project for about a month and returned and didn’t realize I was setting the connections which is pointless: URLSessionWebSocketTask does not provide a direct way to set the maximum message size for a WebSocket connection.

So All I can do is parse the message in chunks when it is received. But it won’t even get delivered to the application because of its size. This must be a mobile/iOS limitation. I would think the api would account for this since most of the devices using the api will be mobile devices, I would think.

In that case is not this property you want to change?:

From documentation:

Connected clients should increase their web socket receive buffer to the largest configurable amount possible (given any client library or infrastructure limitations), due to the potential volume of data for any given product.

Documentation even suggest to set to largest possible amount. You are not doing that, instead you are using default value. And in case if limit not changeable you will need to assume that URLSessionWebSocketTask is not suitable for task and will need to look at other websocket client.