Using websockets in Extensions?

Hi, i’m brand new to the Twitch dev universe. I have successfully set up client/server communication in my Extension EBS, thru ajax requests. Is it possible to use websockets? The docs don’t mention it at all, and i’m not sure that you can use JWT with websockets.

While it doesnt mention “Web Sockets” explicitly, the Docs do mention this…

By default, all assets must be loaded from the Twitch CDN, except the following:

  • You can connect to any HTTPS or WSS endpoint (i.e., for purposes of an XHR)

HTTPS = HyperText Transfer Protocol Secure
WSS = Web Socket Secure

So while yes, you can you Web Sockets, they must be a secure web socket connection, just like HTTP requests MUST be HTTPS secure requests.

This is par for the course, however, as there is a large move from HTTP to HTTPS traffic, and Google.com and Chrome, in many cases, are warning users who browse to insecure HTTP hosted websites.

This is par for the course, however, as there is a large move from HTTP to HTTPS traffic, and Google.com and Chrome, in many cases, are warning users who browse to insecure HTTP hosted websites.

While this is true and good, the much simpler reason I guess is that a non-HTTPS access from the extension’s iframe just wouldn’t be allowed in an HTTPS context (which Twitch is by default) by common browsers.

1 Like

So, can we use Socket.io for long communications, if we do it on HTTPS or is it must to use twitch pub-sub?

I am not too sure what you are trying to do @jerrysimpson, but I will do my best to clear things up. You can use websockets to communicate between your extension and your EBS if you want. The socket connection will need to use TLS.

1 Like

Hi.

I was asking if we can use socket.io (https://socket.io/). From your answer I understand that yes, as long as I use TLS, is it right?

Also, if I use TLS, should I still pass the JWT code?