itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
557 stars 167 forks source link

No response in CURL #128

Open skyppye opened 1 year ago

skyppye commented 1 year ago

Hi, I've been trying to power on a smart plug via a LAN curl command. I get no response whatsoever, any ideas please?? Thanks! Capture 1

tosiara commented 1 year ago

Same for me:

$ curl -vv http://192.168.2.144:8081/zeroconf/info -H "Content-Type: application/json" --data '{ "deviceid": "","data": { }}'
*   Trying 192.168.2.144:8081...
* TCP_NODELAY set
* Connected to 192.168.2.144 (192.168.2.144) port 8081 (#0)
> POST /zeroconf/info HTTP/1.1
> Host: 192.168.2.144:8081
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 29
> 
* upload completely sent off: 29 out of 29 bytes
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
vl9invocations commented 1 year ago

Hello there, anyone resolved this question? What seems to work is using json data saved in txt file, then just use -d @json.txt But I don't really understand why it's not working directly from cli (text formatting have no effect on outcome).

Same issue with C# HttpClient, it hangs or not responding. Checked with external api and it seems to send correct post content.. But with R3 in diy, R3 hangs or drops connection.

edit: Turns out, json data sent to device was somehow malformed and was not read as JavaScript Object Notation (JSON). Used NewtonSoft.Json instead to serialize an object and posted with httpclient PostAsync..

tosiara commented 1 year ago

I've got an answer from support that not every device supports DIY mode. Specifically S26R2 does not support. I returned that back to the shop. Not planning to buy Sonoff anymore