Debugging Network Issues


(Warren Schilpzand) #1

Hi,

I’m building a device type handler that makes calls to rest endpoints on my local LAN. At present, I’m just using the httpPost method with a simple URI and action in the body. However I keep getting “Connect to 192.168.1.8:8080 timed out” when testing from the code screen connected to a physical device. On my mobile I nothing happens when I click the tile and nothing in the logs.

I can ping the smartthings hub from the server and have verified that the uri generated by the code works. Is there any other information that I can use to debug this?

Here is the code that I’m using:

private put(action){
	/*rest(
    	method : "POST",
        headers: ["Authorization": "Bearer ${apiKey}"],
        endpoint: "http://192.168.1.8:8080",
		path: "/rest/items/${device.deviceNetworkId}/${action}",
    )*/
    log.debug("http://192.168.1.8:8080/rest/items/${device.deviceNetworkId}")
    httpPost("http://192.168.1.8:8080/rest/items/${device.deviceNetworkId}", action)

}

(Florian Z) #2

Hi @warrenschilpzand. Last time I checked, there was no support for accessing LAN devices from within a SmartThings app or device handler, although support for this is supposedly forthcoming.

In the meantime, keep in mind that your Groovy code will execute on the SmartThings executor, which lives “in the cloud”, i.e. it won’t run on your hub, but rather a machine somewhere in a data center. Of course, accessing a LAN IP from outside of your local network, makes no sense. What you need to do is expose your machine (192.168.1.8) to the outside world, i.e. opening up port 8080 on your firewall and forwarding that port through your NAT box. You will also need a static IP address or maybe a dynamic DNS service, which will map your dynamic IP address to a static URL.

Once you got that setup, you should be able to access your server from the outside world and be able to access it from your device handler. So, instead of using 192.168.1.8:8080, you’d be using something like myservice.dyndns.org:8080. Does that make sense?

Also, you’d probably want to have some sort of authentication scheme in place, to prevent random clients from accessing your device data, or modifying your devices state.


(Warren Schilpzand) #3

Ah. I was hoping that was not the case :-(. I’ve set up a dyndns and making progress.

Thanks for that.


(Eric M) #4

Dang, that is too bad. I am trying local LAN access as well.

If I do open up my system to the outside world, I’d like to use authentication and use https instead of http. I can’t find anything in the documentation about that. Anyone have any tips?