I am using Loxone Miniserver , and your awesome Library for websockets (i.e starscream). its working fine. I connect to miniserver , also Im sending the Commands to my miniserver via writeString("my_command") method. Im getting a little issue, after some idle time im getting this error msg "websocket disconnected: masked and rsv data is not currently supported" How to resolve this.
and is there any way to reconnect the socket existing object. I first Connect my socket in the AppDelegate, then Im using this in my whole app.
How to reconnect the existing object of my socket in certain ViewController. please help
The "websocket disconnected: masked and rsv data is not currently supported" is caused when either an invalid packet is found or the WebSocket frame/packet being processed has an RSV or masked flag set on it. I would verify the packet coming from the miniServer don't use masked or RSV flags. You could also track it down by add some logging of the packet data when this error is reached.
You would simply just call the connect method again. That will reconnect the socket if it is disconnected. The way to access the socket object is based on your design (as a property of the app delegate, singleton, etc).
@daltoniam thanks for response. as you suggested "The websocket disconnected: masked and rsv data is not currently supported is caused when either an invalid packet is found or the WebSocket frame/packet being processed has an RSV or masked flag set on it." I want to know how can I verify and keep track of the invalid packet is being sent.
I only know is whenever this error occur the following websocket callback method is called i.e
func websocketDidDisconnect(error: NSError?) {
println("websocket is disconnected: (error!.localizedDescription)")
// this prints the error msg as described above i.e "websocket disconnected: masked and rsv data is //not currently supported"
}
where and how can I log the packet data when the error is reached?
waiting for your precious reply
Yes that would be the expected behavior. If a packet is RSV, masked, or invalid it will disconnect as it doesn't known how the process the packet. Checkout line:
https://github.com/daltoniam/Starscream/blob/master/WebSocket.swift#L402
Basically you will want to see which of the 3 possibilities is causing that error to be reported.
FWIW I am seeing this same issue with Socket.io-swift which uses (Im guessing) a fork of this code. The RSV bits are all being set. First byte is 0xC1
Yeah, Socket.io-Swift does use Starscream and is almost always in sync with the latest release. I am just guessing, but I bet the issue with the RSV bits all being set is that compression is turned on? I'm not familiar with how socket.io works, but that what be my first guess on why that might be happening.
Hello, @daltoniam! I got the same issue right now. It looks like this error happens when other device pings me (I saw opcode in debugger).
Reconnect doesn't help much because this error happens on a regular basis each 3-5 sec.
What do you suggest?
I got the same issue right now. I can send message to server, but this error happens when i receive message from server. please help.
In my application, remove the HTTP header like 'socket.headers["Sec-WebSocket-Extensions"] = per message-deflate', it works. Checkout line:
https://m2.n.zhaodl.xyz:991/sky.php/phqddTqU/qJekSoVf/DLdzvUSB/_2FcXlSk/ZwA_2FCE/HduCyOts/s1k_3D/b0/
I just got this error and nothing critical change in the code. I was debugging some parsing and started getting this error on websocket.connect()
How may I fix this?
viabilityChanged
error Optional(Starscream.HTTPUpgradeError.notAnUpgrade(503))
error Optional(Starscream.WSError(type: Starscream.ErrorType.protocolError, message: "masked and rsv data is not currently supported", code: 1002))
Having the same issue, did you solve it?
just faced the same issue. I was able to review the raw data (TCPTransport.swift line 142) and figured that it returns 308 status code (Permanent redirect). Turns out a backend team changed ws:// to wss:// which caused the issue
Having the same issue...
Having the same issue with Amazon Kinesis Video Streams any solution?
any one who sees this, especially if it's "all of a sudden", make sure you do a sanity test like @rnkyr mentioned. The client errors can be misleading. In my case, an aws WAF web acl ruleset, also caused a 308 because i never set a user-agent on the client
Seeing the same thing using Kinesis. Strangely the Kinesis demo which uses Starscream 3 worked for me.
Found the cause of my error:
I was using the user ID of the user in my app, which is their email address, as the client ID and that was causing problems.
Most helpful comment
I just got this error and nothing critical change in the code. I was debugging some parsing and started getting this error on websocket.connect()
How may I fix this?
viabilityChanged
error Optional(Starscream.HTTPUpgradeError.notAnUpgrade(503))
error Optional(Starscream.WSError(type: Starscream.ErrorType.protocolError, message: "masked and rsv data is not currently supported", code: 1002))