Developers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Wadimir
Newbie

wss via roStreamSocket

Hi,

I am trying to use "wss" via roStreamSocket and nothing works for me

function listenSocket()
    messagePort = CreateObject("roMessagePort")
    sendAddress = CreateObject("roSocketAddress")
    sendAddress.setHostName("adress.com") 'wss://adress.com
    sendAddress.setPort(443)

    m._socket = CreateObject("roStreamSocket")
    m._socket.setMessagePort(messagePort)
    m._socket.notifyReadable(true)
    m._socket.notifyWritable(true)
    m._socket.notifyException(true)
    m._socket.setSendToAddress(sendAddress)
    m._socket.setKeepAlive(true)

    buffer = CreateObject("roByteArray")
    buffer[1024] = 0

    localStatus = m._socket.sendStr("subscription")

    while True
        event = wait(0, messagePort)

        if type(event) = "roSocketEvent"

            if event.getSocketID() = m._socket.getID() and m._socket.isReadable()
                received = m._socket.receive(buffer, 0, 1024)

                if received <> -1
                    print "WebSocket received data "
                end if

            end if

        end if

    end while
end function

localStatus = -1 for me

received = -1 for me

wss://adress.com - it is a fake address I have a real one

what am I doing wrong?

Tags (1)
0 Kudos
3 REPLIES 3
RokuKC
Roku Employee
Roku Employee

Re: wss via roStreamSocket

The roStreamSocket needs to have a Connect call made on it to start.

https://developer.roku.com/docs/references/brightscript/components/rostreamsocket.md

 

0 Kudos
_Maximus_
Newbie

Re: wss via roStreamSocket

Can you confirm that roStreamSocket supports WSS?  

0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: wss via roStreamSocket

roStreamSocket is plain TCP/IP only.  It doesn't know anything about WebSockets.

I believe someone mentioned before some open source BrightScript code that implements a WebSocket class.  Maybe you could look into that, but I haven't looked at it myself.

0 Kudos
Community is Being Upgraded!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

We're sorry for this disruption — we’re excited to share what’s next!