Starscream: Masked and rsv data is not currently supported code 1002

Created on 7 Jun 2020  ·  7Comments  ·  Source: daltoniam/Starscream

Hi, I was debugging normaly testing some parsing and now I'm getting this error on websocket.connect() I did a rollback on my minor changes and the error persists.

this is the log:
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))

question

Most helpful comment

I solved this question!
First I use domain connect,not ip connect!
Reason:
WSEngine --> connectionChanged(state: ConnectionState) --> let wsReq = HTTPWSHeader.createUpgrade(request: request, supportsCompression: framer.supportsCompression(), secKeyValue: secKeyValue) --> HTTPWSHeader.createUpgrade --> let hostValue = req.allHTTPHeaderFields?[HTTPWSHeader.hostName] ?? "(parts.host):(parts.port)"
req.setValue(hostValue, forHTTPHeaderField: HTTPWSHeader.hostName)
If we do not set Host,default value is "(parts.host):(parts.port)", if we use domin connect, Host's value is like "ws://api.ws.cn:80".
The Host's value is like "ws://api.ws.cn" without port. And this por 80 is default, our server‘s port is 7000. So connection is 503.

I set Host when created URLRequest,Eg:
let URL = URL(String:"......")
let request = URLRequest(url: URL)
request.setValue(URL.host, forHTTPHeaderField: "Host")

Hope usefully.

All 7 comments

Today it was working again.. so it's something that the server replies. I'm consuming an exchange server, so I wouldn't have access to know what it was sending.

I have the same problem! but it works when I use ip connect, not works for domain。

HTTP/1.0 503 Service Unavailable\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n

503 Service Unavailable

\nNo server is available to handle this request.\n

Optional(Starscream.HTTPUpgradeError.notAnUpgrade(503))
Optional(Starscream.WSError(type: Starscream.ErrorType.protocolError, message: "masked and rsv data is not currently supported", code: 1002))

I solved this question!
First I use domain connect,not ip connect!
Reason:
WSEngine --> connectionChanged(state: ConnectionState) --> let wsReq = HTTPWSHeader.createUpgrade(request: request, supportsCompression: framer.supportsCompression(), secKeyValue: secKeyValue) --> HTTPWSHeader.createUpgrade --> let hostValue = req.allHTTPHeaderFields?[HTTPWSHeader.hostName] ?? "(parts.host):(parts.port)"
req.setValue(hostValue, forHTTPHeaderField: HTTPWSHeader.hostName)
If we do not set Host,default value is "(parts.host):(parts.port)", if we use domin connect, Host's value is like "ws://api.ws.cn:80".
The Host's value is like "ws://api.ws.cn" without port. And this por 80 is default, our server‘s port is 7000. So connection is 503.

I set Host when created URLRequest,Eg:
let URL = URL(String:"......")
let request = URLRequest(url: URL)
request.setValue(URL.host, forHTTPHeaderField: "Host")

Hope usefully.

I have the same problem, it happen when I use ip connect via lan.
It quickly received this error(Starscream.WSError(type: Starscream.ErrorType.protocolError, message: "masked and rsv data is not currently supported", code: 1002)) when the websocket connected.

Did you get to fix this?

FYI: Since I looked into how to reproduce this issue, I created a PR and put together the detail.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrian-niculescu picture adrian-niculescu  ·  4Comments

fassko picture fassko  ·  6Comments

marknorgren picture marknorgren  ·  5Comments

lveselovsky picture lveselovsky  ·  3Comments

gmosx picture gmosx  ·  4Comments