daltoniam / Starscream

Websockets in swift for iOS and OSX
Apache License 2.0
8.35k stars 1.21k forks source link

Why is a close code of 1012 considered a protocol error? #374

Closed p0fi closed 7 years ago

p0fi commented 7 years ago

Hi,

im wondering why the following lines

https://github.com/daltoniam/Starscream/blob/6dc9cdffbc61aef0ccc3e183d796f3251c8ce603/Source/WebSocket.swift#L805-L807

assume that a close code of 1012 is a protocol error?

The code seems to be added as an extension of RFC 6455 here: https://www.ietf.org/mail-archive/web/hybi/current/msg09670.html

The web API description by mozilla (link) also lists 1012 as a valid close code with the meaning

Service Restart - The server is terminating the connection because it is restarting.

acmacalister commented 7 years ago

Yeah, those opcode aren't apart of the 6455 RFC spec, but you are correct that they appears to have been added to the official IANA registry. Starscream was designed against the original 6455 RFC spec, so that is why we made an assumption those were protocol errors. They were updated in the autobahn test suite (see https://github.com/crossbario/autobahn-testsuite/issues/52 for more info), so we will go ahead and update them accordingly in Starscream. Thanks for the report.

daltoniam commented 7 years ago

Version 3.0.0 has been released with a fix for this!

karthik55 commented 6 years ago

I am getting ProtocolError With close Code 1000 and Message is Empty, any one come across issue. If so could you tell me the reason for the issue.