Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Header in Websocket


Question

Guest
Posted

Trying to achive something like this python line in a QA.

I connect, send commands etc but cannot find how to include the "header"

 

asyncio.run(client.subscribe(query=query, headers={'Authorization': "d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a"}, handle=print_handle))

 

Should it go into the connect or into the send command? (From the API (

Please login or register to see this link.

) it says it should be included in every request. (and I have it working in a http request (where it is not streaming data)

 

Below suggestion (with errors)

function QuickApp:onInit()
    local url = self:getVariable("SubscriptionURL")
    self.sock = net.WebSocketClientTls()
 
    self.sock:addEventListener("connected", function() self:handleConnected() end)
    self.sock:addEventListener("disconnected", function() self:handleDisconnected() end)
    self.sock:addEventListener("error", function(error) self:handleError(error) end)
    self.sock:addEventListener("dataReceived", function(data) self:handleDataReceived(data) end)
 
    self.sock:connect(url, headers={'Authorization': \"Bearer -Hti3bM2BLhGx2XxRAqvzV7cDEg\"}")
    self:debug("onInit")
end

1 answer to this question

Recommended Posts

  • 0
Posted

normally you have to create wrapper for that, like GraphQL or JSON RPC is doing, to be able to send extra info like headers.
Here some

Please login or register to see this link.

 

Fibaro is using for their Intercom JSON RPC over WebSockets, which in principle build the necessary info and send it right after sock:connect.

So you might try something like:

Please login or register to see this code.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...