Can not open websocket on iOS

86 views
Skip to first unread message

quang phungbuu

unread,
Jul 13, 2021, 3:24:01 AM7/13/21
to Tinode General
I can't open websocket on app iOS although follow your guide on Github SwiftWebSocket.
Please help me and reply if you have any question.

Gene

unread,
Jul 13, 2021, 8:50:47 PM7/13/21
to Tinode General
On Tuesday, July 13, 2021 at 12:24:01 AM UTC-7 quang phungbuu wrote:
I can't open websocket on app iOS although follow your guide on Github SwiftWebSocket.
Please help me and reply if you have any question.

You have to be more specific than this. The app works.
 

quang phungbuu

unread,
Jul 13, 2021, 9:14:57 PM7/13/21
to Tinode General
I can't open websocket on app iOS although follow your guide on Github SwiftWebSocket.
Please help me and reply if you have any question.
Vào lúc 07:50:47 UTC+7 ngày Thứ Tư, 14 tháng 7, 2021, Gene đã viết:

Gene

unread,
Jul 14, 2021, 12:53:00 AM7/14/21
to Tinode General
If you need help, then please describe the problem in as much details as you can.

quang phungbuu

unread,
Jul 14, 2021, 3:10:35 AM7/14/21
to tin...@googlegroups.com
Thanks for your reply. I used your SDK by importing the file WebSocket.swift to my project. 
This is code connect websocket : 

let ws = WebSocket("wss://stg-chat.sumo-cha.com")

But it isn't connected. I receive log: 

web socket error ---- InvalidResponse(HTTP/1.1 200 OK)

web socket close ---- 0

I don't know I missed any thing else. If you have any question please let me know.
Vào Th 4, 14 thg 7, 2021 vào lúc 11:53 Gene <ge...@tinode.co> đã viết:
--
You received this message because you are subscribed to a topic in the Google Groups "Tinode General" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tinode/pbXQIKjCWG4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tinode+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tinode/d8e19a4b-34a4-4a0b-bfd9-8cb6bea39c5en%40googlegroups.com.

Gene

unread,
Jul 14, 2021, 2:42:28 PM7/14/21
to Tinode General
The error you are getting is due to your web server. The web server at stg-chat.sumo-cha.com must support websockets. It does not:

curl -I --include \
  --no-buffer \
  --header "Connection: Upgrade" \
  --header "Upgrade: websocket" \
  --header "Host: stg-chat.sumo-cha.com" \
  --header "Origin: https://stg-chat.sumo-cha.com" \
  --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
  --header "Sec-WebSocket-Version: 13" \
  https://stg-chat.sumo-cha.com/


The correct response should be 
HTTP/1.1 101 Switching Protocols

The actual response is wrong:

HTTP/2 200

It also does not make any sense to me why you use WebSocket library directly instead of using the SDK. What you are doing seems to be unrelated to Tinode.


Gene

unread,
Jul 14, 2021, 2:52:13 PM7/14/21
to Tinode General
Just for the record, here is the full log:

$ curl -o - --http1.1 --include --no-buffer --header "Connection: Upgrade" --header "Upgrade: websocket" --header "Host: stg-chat.sumo-cha.com" --header "Origin: https://stg-chat.sumo-cha.com" --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" --header "Sec-WebSocket-Version: 13" https://stg-chat.sumo-cha.com/
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 14 Jul 2021 18:50:33 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 18
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: must-revalidate, public, max-age=39600
Last-Modified: Tue, 29 Jun 2021 02:18:42 GMT
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff

Silent is golden!

Reply all
Reply to author
Forward
0 new messages