Smartthings Timed Out when running a function?


#1

I get this error java.net.SocketTimeoutException: Read timed out

When running a function that takes more than 10 seconds.
What is the best way to resolve this issue?

This is a part of a device type where a call asks a Particle Photon to run a function that has a delay in it.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

You need to call asynchronously.

http://docs.smartthings.com/en/latest/ref-docs/async-http-ref.html


#3

Ok. So I tried that and I get a 400 Error (Failed with status code 400).

Here is my code:

private sendToDevice(cmd) {
    
    def params = [
        uri: "https://api.particle.io",
        path: "/v1/devices/${deviceId}/${query}",
        body: [access_token: token, command: "${cmd}${duration}"]
    ]
    
    asynchttp_v1.post('processResponse', params)
    
}
def processResponse(response, data) {log.debug (response.data)}

Here is what I had originally:

private sendToDevice(cmd) {
	httpPost(
		uri: "https://api.particle.io/v1/devices/${deviceId}/${query}",
		body: [access_token: token, command: "${cmd}${duration}"],  
	) {response -> log.debug (response.data)}
}

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #4

Error 400 generally indicates a mis-formatted request.

Unfortunately, I don’t know enough about the the quirks of the AsyncHttp API to debug it.

I suggest trying a super simple case against a web server that you can use to view and debug the incoming request, and incrementally iterate until it works.

You can also search the forum for example uses of “asynchttp”.


#5

I figured it out. Thank you very much for the suggestion. Your solution worked!