rkosegi / tuya-smartplug-exporter

Prometheus exporter for Tuya-based smartplug devices
Apache License 2.0
15 stars 3 forks source link

Error during scrape #87

Closed Jared0430 closed 1 month ago

Jared0430 commented 4 months ago

Hi, I have just purchased some Tuya smart plugs and am trying to get them connected with this package.

I grabbed my local keys using npx @tuyapi/cli wizard and setup my config file, but I am getting this error every time I try to scrape

ts=2024-05-10T16:59:24.467Z caller=exporter.go:56 level=warn msg="error during scrape" device=PC error=EOF
ts=2024-05-10T16:59:24.673Z caller=exporter.go:56 level=warn msg="error during scrape" device=AC error=EOF
ts=2024-05-10T16:59:24.867Z caller=exporter.go:56 level=warn msg="error during scrape" device=Server error=EOF

Let me know if there's a way I can get more info and thanks for the help!

EDIT: I've done some tracing and the issue is coming from pkg/proto/client.go:

func (p *proto) exchange() ([]byte, error) {
        // ...

    inbuffer := make([]byte, 256)
    read, err := conn.Read(inbuffer) // <--

if that helps debug the issue, I'm not very familiar with Go

rkosegi commented 4 months ago

Hi @Jared0430, EOF during read means that device closed connection before read completes. Not sure what to do with that :man_shrugging:

Jared0430 commented 4 months ago

I also tried connecting to my device with codetheweb/tuyapi and am getting a similar issue, with the socket being immediately closed. It seems this may be a problem with Tuya protocol version 3.4.

After applying the fix from https://github.com/helberhlm/tuyapi/commit/bd28e0febd9628bf22f5adb02732dc778521bed6 the connection seems to work correctly.

github-actions[bot] commented 2 months ago

This issue has been marked 'stale' due to lack of activity. The issue will be closed in another 30 days.

github-actions[bot] commented 1 month ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.