I’m trying to do a simple HTTP NOTIFY to the hub, based on example code that I’ve found:

subscribe(location, null, lanResponseHandler, [filterEvents:false])

I’m doing a simple request with Python:

req = urllib.request.Request('', 
method='NOTIFY', headers=headers, data=myjson)
response = urllib.request.urlopen(req)

The thing is, it works some of the time. Sometimes it works fine, my SmartApp gets the data, the mobile app shows the update, etc.

Other times, the hub just doesn’t respond. Here’s a working request:

NOTIFY /notify HTTP/1.1
Accept-Encoding: identity
Connection: close
Device: temperature
Content-Length: 23
Content-Type: application/json
User-Agent: Python-urllib/3.5

{"temperature": "57.6"}

And the server sends back a response:

HTTP/1.1 200 OK
Connection: close

Other times, nothing. The request is exactly the same, but the hub doesn’t send back an HTTP OK (or any message), so my script just hangs there. I would say this happens most of the time.

If I ctrl+c and rerun my test script over and over, eventually one will get through. I can actually telnet to the same port and paste the request, and the same thing happens. Sometimes it works, other times I have to terminate telnet, try again, and paste the same request. Eventually it will work.

Does anyone have any idea about what could be happening?



I rebooted the hub and now every request works perfectly. While I’m glad it’s working, it gives me doubts about long term reliability. I guess this kind of thing is par for the course with SmartThings. :frowning:

1 Like

I know this is an old post but can you share how your SmartApp work. I want to do something similar.