Hi Folks,
I am trying to develop a device handler. As part of the implementation I need to use a Eventstream to connect to an endpoint to get events from the device.
So I have been following the instructions for the Eventstream here - EventStream Interface - Hubitat Documentation
Now, connecting seems to work ok, using the following:
def openStream(){
interfaces.eventStream.connect("https://my.arlo.com/hmsweb/client/subscribe",[
pingInterval: 5,
headers:[
Authorization: state.token,
"Content-Type" : "application/json; charset=utf-8",
"User-Agent" : "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B202 NETGEAR/v1 (iOS Vuezone)",
Accept : "application/json",
Cookie: state.cookie
]
])
}
However, I need to disconnect the Eventstream when I reconfigure things, or when their is a new API Key, and that doesn't seem to work.
def closeStream(){
log.debug "closing event stream"
interfaces.eventStream.close()
eventStreamClose()
state.connected = false
}
What I would expect so see is an event sent to the eventStreamStatus() function indicating that the stream has been closed. However the stream seems to stay open, and the stream will eventually close around a minute later with the following events. This is just the standard timeout as I stop sending the keepalive ping to the endpoint when I am calling close on the stream.
[dev:689](http://192.168.1.220/logs#dev689)2020-01-02 09:59:36.610 pm [debug](http://192.168.1.220/device/edit/689)STOP: EventStream Stopped
[dev:689](http://192.168.1.220/logs#dev689)2020-01-02 09:59:36.595 pm [debug](http://192.168.1.220/device/edit/689)ERROR: Exception during EventStream Request: java.net.SocketTimeoutException: timeout
Has anyone else used the Eventstream and have any idea where I'm going wrong, or any code they can share.
The Eventstream is a bit of a black hole so it's difficult to really know what's going on under the hood, and the documentation is sparse . . .
Thanks
Gareth