Eventstream broken in Release 2.4.3.133

the parse() function is not called.
eventStreamStatus() gets called on start/stop etc.
the eventstream connects and is sent data
as I viewed the connected server logs

eventStreamStatus() called - START: EventStream Started

I rolled firmware back to 2.4.3.131 and it is working
i will update again to 2.4.3.133 to confirm

did update to 2.4.3.133, parse() not being called
rolled back to 2.4.3.131, all WORKING

so confirmed, 2.4.3.133 has broken by code that uses interfaces.eventStream.connect()

did i post this in the right forum?

I'm having the same issue, any hope for a fix soon?

at this point some acknowledgement from Hubitat would help

Tagging @support_team from Hubitat to make sure they are aware of this reported issue.

1 Like

We are looking into it, but there have been no recent changes.

2 Likes

@bobbyD

I just updated to 2.4.3.137
and lost callbacks into parse, but I had a hunch
changed the rawData to true

in my initialize()
interfaces.eventStream.connect(url, [
pingInterval: 10,
readTimeout: 60,
headers:["Accept": "text/event-stream"],
rawData: true
])

// data from eventStream
void parse(String response) {
log.debug("parse(): ${response}")
}

and sure enough, parse() now gets called

when I was at 2.4.3.131 & rawData: false, parse() string would be:
parse(): { "upTime": 24915162, "freeHeap": 116376, "minHeap": 45084, "wifiRSSI": "-39 dBm, Channel 6" }

now its like the backend isnt preparsing message data
here is the result when rawData set to true:

parse():
parse(): data: { "upTime": 25795256, "freeHeap": 113324, "minHeap": 45084, "wifiRSSI": "-40 dBm, Channel 6" }
parse(): event: message

so get

  1. event:message
  2. data: { "upTime": 25795256, "freeHeap": 113324, "minHeap": 45084, "wifiRSSI": "-40 dBm, Channel 6" }
  3. empty string

rawData:false is what i want to use, as the JSON at that point ready to parse

sse.dev
is a good site to test against this
i have written a driver that does and only when rawData: true
does it call parse()

/*
 *
 * interfaces.eventStream tester
 *
*/
import groovy.transform.Field

@Field static def shouldReconnect = false
    
metadata {
    definition(name: "EventStream-Tester", namespace: "MJS Gadgets", author: "MitchJS", importUrl: "") {
        capability "Initialize"
        command "disconnect"

        attribute "eventStreamStatus", "string"
        attribute "networkStatus", "enum", ["offline","online"]
    }
}

preferences {
}

def initialize() {
    log.debug("initialize() called")
  
    // temporally prevent reconnection
    if (device.currentValue("eventStreamStatus") == "Connected") {
        shouldReconnect = false
    }
    
    sendEvent(name:"networkStatus", value: "offline")
    
    sendEvent(name: "eventStreamStatus", value: "Connecting", descriptionText:"${device.displayName} eventStreamStatus is Connecting")

    log.debug("initialize() called, request subscribe to SSE")

    try {
        // SSE test url        
        url = "https://sse.dev/test?interval=5"
        
        log.debug("initialize() subscribing to events via interfaces.eventStream.connect(${url})")
 
        // connect to SSE
        interfaces.eventStream.connect(url, [
            pingInterval: 10,
            readTimeout: 60,
            headers:["Accept": "text/event-stream"],
            rawData: false 
        ]) 
    }
    catch (Exception e) {
        log.error "initialize() Execption: ${e}"

        runIn(10, initialize)
    }
}

def disconnect() {
    log.debug("disconnect() called")
    
    if (device.currentValue("eventStreamStatus") == "Connected") {
        shouldReconnect = false;
        interfaces.eventStream.close()
    }
}

// data from eventStream
void parse(String response) {
    log.debug("parse() ${response}")
}

def eventStreamStatus(String message) {
    log.debug("eventStreamStatus() ${message}")
    
    if (message.startsWith("START:")) {
        sendEvent(name:"networkStatus", value: "online")
        sendEvent(name: "eventStreamStatus", value: "Connected", descriptionText:"${device.displayName} eventStreamStatus is Connected")
        shouldReconnect = true;
    }
    else if (message.startsWith("STOP:")) {
        sendEvent(name:"networkStatus", value: "offline")
        sendEvent(name: "eventStreamStatus", value: "Disconnected", descriptionText:"${device.displayName} eventStreamStatus is Disconnected")
        
        // try to reconnect
        if (shouldReconnect == true) {
            log.debug("eventStreamStatus() will re-init")
            runIn(5, "initialize")
        }
    }
    else if (message.startsWith("ERROR:")) {
        sendEvent(name:"networkStatus", value: "offline")
    	sendEvent(name: "eventStreamStatus", value: "Disconnected", descriptionText:"${device.displayName} eventStreamStatus is Disconnected")
        if (message.contains("SocketTimeoutException")) {
            // try to reconnect
            log.debug("eventStreamStatus() will re-init")
            runIn(5, "initialize")
        }
    }
}

1 Like

bump

When is the last time you re-tested? There were some changes in recent builds (not sure if they are still in beta) that may help.

im running 2.4.3.137
and the rawData: false results in no callbacks to Parse()
the demo code i posted will show that

There are newer betas currently in testing. I would wait for a release next week (assuming you are not in beta), re-test, and follow up if the problem still happens then.

yes, im not in the "beta" and i can wait
i added a bunch of code to get it working

It started working after 2.4.3.149 update :slight_smile:

3 Likes

well... its not 100% right

as you can see now parse() is called twice!
should only be called with the actual JSON
not the "data :" prefix when i set rawData to false
but its NOW closer to prior behavior!

// connect to SSE
interfaces.eventStream.connect(url, [
    pingInterval: 10,
    readTimeout: 60,
    headers:["Accept": "text/event-stream"],
    rawData: false
])

progress is good :slight_smile:

thanks HE team!
@bobbyD

It's exactly the prior behavior now. Once we started getting enough reports to determine it wasn't a fluke, the changes got rolled back. The changes made it through both internal testing and beta, but if it causes problems, it goes.

Ok... so now i test, and its only calling parse() once!
like it should

strange, i swore it called in twice :slight_smile:
and i screen shot it...

the good news it is working like it should

thanks
Mitch

2 Likes