Jump to content

Trouble sending HTTP POST from ISY Network module


Recommended Posts

Posted

Hi,

In an effort to start sending data from my ISY to a new service, I bought the Networking module. I am trying to get it to send an HTTP POST and having trouble. When I failed to send the POST to the actual 3rd party service, I tried sending it to my laptop instead.  My test is to have `nc` listening on port 8089; I expect to see the HTTP content show up there.

Here's an example of it working when using `nc` to listen and `curl ` to send the POST:

➜  sleep 1 && curl -X POST -d '{"source":"isy","device":"garage"}' localhost:8089/1/events/isy -H "X-Honeycomb-Team: abcd1234" & nc localhost 8089 -l
POST /1/events/isy HTTP/1.1
Host: localhost:8089
User-Agent: curl/7.54.0
Accept: */*
X-Honeycomb-Team: abcd1234
Content-Length: 34
Content-Type: application/x-www-form-urlencoded

{"source":"isy","device":"garage"}

When I have `nc` listening on my laptop and configure the ISY to send the POST, I get no data sent to my laptop. Here are screenshots of the configuration in the network resources tab:

1915734306_Image2018-11-26at11_50_12AM.thumb.png.32684bb92b64f17e4fbff78fea6cf6e1.png

And when I save it then click the 'test' button, I get these two popups: the Resource Response with the text "N/A" and the Error: Request Failed.

1454930003_Image2018-11-26at11_49_51AM.thumb.png.5c3ec0b7aac759605365ff74aea836b1.png

How can I find out more? What was the request that failed? Why did it fail? What should I do to fix it? I have found very little documentation on the networking module or suggestions on where to look to find more.  Any links to manuals or places I should RTFM would be greatly appreciated.

Thanks,

-ben

p.s. firmware 5.0.14.

1276115865_Image2018-11-26at11_50_31AM.thumb.png.95cd0b523e1f7d34584ffe69bbef2ac6.png

Posted

Is nc (netcat) listening on the 192.168.1.113 IP address? Or only on localhost? Do you have a firewall on the host blocking ISY from connecting to the port netcat is listening On? You rule looks fine to me otherwise...

Have you tried a curl to your netcat ‘server’ from a machine other than the machine itself (and ISY) to ensure it’s listening properly...

Posted

Hi MWareman,

Thanks for your reply. I checked that there was no firewall preventing connections. When I ran `netstat -nal | grep 8089` to see how it was listening it was only listening for ipv6 connections! Oy. Ok, good call testing that. When I changed it to listen on both ipv4 and ipv6 (turns out I should have left off the 'localhost' to just run `nc -l 8089`).

So there were two reasons I was trying to connect to `nc` on my laptop: make sure the network module could at least do a POST in a controlled environment and learn more about how to debug issues with it making requests.  While your question helped me confirm the former, I still feel pretty feeble with the latter. (Something about "connection refused" would have been much more helpful than a generic "request failed".)

My real goal is to POST an update to Honeycomb.io (I work there), and when I try I get a different error. Turns out this one is that it replied with HTTP status code 401 (permission denied). I had an error in my authentication token.

740535132_Image2018-11-26at9_28_29PM.png.13991e28a36201e69cb362d47f1de768.png

I fixed that and got a different error. This one means "the POST succeeded." ... it's not actually an error; the thing worked. But it still popped up an error. I don't know why.

1326538238_Image2018-11-26at10_08_39PM.png.21ea7e723261d6a2ffd4d1cc339296ca.png

So I don't know what happened the first time around to make my attempt fail; it seems to work now.

Is there any other method to find out more about the requests the ISY is sending and the responses it gets back? Any tips to debugging as I continue down this road? It's been pretty frustrating so far.

Thanks again for the help.

-ben

 

Posted

To debug, I set the switch port that the ISY is connected to to mirror the traffic to another port, where I have a host running Wireshark. It allows me to see the traffic on the wire, and the response from the server. It’s been very usefully to me (but does require you have a managed switch).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...