Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws api websocket #667

Closed
harymk opened this issue May 21, 2021 · 20 comments
Closed

aws api websocket #667

harymk opened this issue May 21, 2021 · 20 comments

Comments

@harymk
Copy link

harymk commented May 21, 2021

20:31:47.058 -> connected with Me, channel 11 20:31:47.058 -> dhcp client start... 20:31:47.107 -> ip:192.168.225.214,mask:255.255.0.0,gw:192.168.225.1 20:31:47.623 -> [WSc] Disconnected! 20:31:53.094 -> [WSc] Disconnected! 20:31:56.999 -> pm open,type:2 0 20:31:58.483 -> [WSc] Disconnected! 20:32:04.339 -> [WSc] Disconnected!

how fix this please help me

@Links2004
Copy link
Owner

please enable debug, with the current info its impossible to help.

@harymk
Copy link
Author

harymk commented May 22, 2021

how to do that

@harymk
Copy link
Author

harymk commented May 22, 2021

is that serial monitor

@Links2004
Copy link
Owner

in the arduino IDE its a setting in the menu where you configure your board.
https://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/debugging.html

for more advanced IDEs you need to set a compile define options.
for example platform IO:

build_flags = -D DEBUG_ESP_PORT=Serial

@harymk
Copy link
Author

harymk commented May 22, 2021

13:56:21.382 -> [SETUP] BOOT WAIT 3...
13:56:22.405 -> [SETUP] BOOT WAIT 2...
13:56:23.421 -> [SETUP] BOOT WAIT 1...
13:56:24.400 -> [WIFIM][APlistAdd] Add SSID: Me
13:56:24.400 -> [WIFIM] Connecting saved WiFi
13:56:24.400 -> fpm close 3 
13:56:24.400 -> mode : sta(d8:bf:c0:11:31:96)
13:56:24.400 -> add if0
13:56:24.400 -> wifi evt: 8
13:56:24.400 -> wifi evt: 2
13:56:24.536 -> scandone
13:56:24.536 -> state: 0 -> 2 (b0)
13:56:24.536 -> state: 2 -> 3 (0)
13:56:24.536 -> state: 3 -> 5 (10)
13:56:24.536 -> add 0
13:56:24.536 -> aid 7
13:56:24.536 -> cnt 
13:56:24.639 -> 
13:56:24.639 -> connected with Mk, channel 11
13:56:24.639 -> dhcp client start...
13:56:24.673 -> wifi evt: 0
13:56:29.426 -> [WIFIM] Connect timeout
13:56:29.426 -> [WIFIM] Start scan
13:56:29.426 -> state: 5 -> 0 (0)
13:56:29.426 -> rm 0
13:56:29.426 -> wifi evt: 1
13:56:29.426 -> STA disconnect: 8
13:56:31.577 -> scandone
13:56:31.577 -> [WIFIM] 3 networks found:
13:56:31.619 ->       0: [CH 11] [52:02:91:7A:15:07] -92dBm   FaryLink_7A1507
13:56:31.619 ->  ---> 1: [CH 11] [A8:6B:AD:10:4C:FD] -68dBm * Me
13:56:31.619 ->       2: [CH 11] [50:C7:BF:F0:91:8F] -66dBm * Mk
13:56:31.619 -> [WIFIM] Sorted indices: 1 
13:56:31.619 -> [WIFIM] Connecting Me
13:56:31.715 -> scandone
13:56:32.555 -> state: 0 -> 2 (b0)
13:56:32.555 -> state: 2 -> 3 (0)
13:56:32.555 -> state: 3 -> 5 (10)
13:56:32.555 -> add 0
13:56:32.555 -> aid 24
13:56:32.555 -> cnt 
13:56:32.592 -> 
13:56:32.592 -> connected with Me, channel 11
13:56:32.592 -> dhcp client start...
13:56:32.592 -> wifi evt: 0
13:56:34.608 -> ip:192.168.225.214,mask:255.255.0.0,gw:192.168.225.1
13:56:34.608 -> wifi evt: 3
13:56:34.608 -> [WIFIM] Connected:
13:56:34.608 -> [WIFIM]   SSID: Me
13:56:34.608 -> [WIFIM]   IP:   192.168.225.214
13:56:34.608 -> [WIFIM]   MAC:  A8:6B:AD:10:4C:FD
13:56:34.608 -> [WIFIM]   CH:   11
13:56:34.608 -> [WIFIM]   RSSI: -72
13:56:34.608 -> [WS-Client] Websocket Version: 2.3.5
13:56:34.608 -> [WS-Client] connect ws...
13:56:34.608 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/
13:56:34.676 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/ lookup error: -5!
13:56:34.710 -> [WS-Client] connection to 3xcls223mg.execute-api.eu-west-1.amazonaws.com/:443 Failed
13:56:34.710 -> [WS-Client] client disconnected.
13:56:34.710 -> [WSc] Disconnected!
13:56:39.703 -> [WS-Client] connect ws...
13:56:39.703 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/
13:56:39.703 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/ lookup error: -5!
13:56:39.750 -> [WS-Client] connection to 3xcls223mg.execute-api.eu-west-1.amazonaws.com/:443 Failed
13:56:39.750 -> [WS-Client] client disconnected.
13:56:39.750 -> [WSc] Disconnected!
13:56:42.564 -> pm open,type:2 0
13:56:44.753 -> [WS-Client] connect ws...
13:56:44.753 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/
13:56:44.753 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/ lookup error: -5!
13:56:44.753 -> [WS-Client] connection to 3xcls223mg.execute-api.eu-west-1.amazonaws.com/:443 Failed
13:56:44.753 -> [WS-Client] client disconnected.
13:56:44.753 -> [WSc] Disconnected!

@Links2004
Copy link
Owner

looks like you have a / at the end of the domain, which results in the DNS lookup failing.

[hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com/ lookup error: -5!

@harymk
Copy link
Author

harymk commented May 22, 2021

14:25:19.672 -> [SETUP] BOOT WAIT 2...
14:25:20.688 -> [SETUP] BOOT WAIT 1...
14:25:21.719 -> [WIFIM][APlistAdd] Add SSID: Me
14:25:21.719 -> [WIFIM] Connecting saved WiFi
14:25:21.719 -> fpm close 3 
14:25:21.719 -> mode : sta(d8:bf:c0:11:31:96)
14:25:21.719 -> add if0
14:25:21.719 -> wifi evt: 8
14:25:21.719 -> wifi evt: 2
14:25:21.813 -> scandone
14:25:21.813 -> state: 0 -> 2 (b0)
14:25:21.813 -> state: 2 -> 3 (0)
14:25:21.860 -> state: 3 -> 5 (10)
14:25:21.860 -> add 0
14:25:21.860 -> aid 13
14:25:21.860 -> cnt 
14:25:21.954 -> 
14:25:21.954 -> connected with Mk, channel 11
14:25:21.954 -> dhcp client start...
14:25:21.954 -> wifi evt: 0
14:25:26.691 -> [WIFIM] Connect timeout
14:25:26.691 -> [WIFIM] Start scan
14:25:26.691 -> state: 5 -> 0 (0)
14:25:26.691 -> rm 0
14:25:26.691 -> wifi evt: 1
14:25:26.691 -> STA disconnect: 8
14:25:28.879 -> scandone
14:25:28.879 -> [WIFIM] 3 networks found:
14:25:28.879 ->  ---> 0: [CH 11] [A8:6B:AD:10:4C:FD] -66dBm * Me
14:25:28.879 ->       1: [CH 11] [52:02:91:7A:15:07] -86dBm   FaryLink_7A1507
14:25:28.879 ->       2: [CH 11] [50:C7:BF:F0:91:8F] -68dBm * Mk
14:25:28.926 -> [WIFIM] Sorted indices: 0 
14:25:28.926 -> [WIFIM] Connecting Me
14:25:28.973 -> scandone
14:25:29.850 -> state: 0 -> 2 (b0)
14:25:29.850 -> state: 2 -> 3 (0)
14:25:29.850 -> state: 3 -> 5 (10)
14:25:29.850 -> add 0
14:25:29.850 -> aid 15
14:25:29.850 -> cnt 
14:25:30.869 -> 
14:25:30.869 -> connected with Me, channel 11
14:25:30.869 -> dhcp client start...
14:25:30.869 -> wifi evt: 0
14:25:32.916 -> ip:192.168.225.214,mask:255.255.0.0,gw:192.168.225.1
14:25:32.916 -> wifi evt: 3
14:25:32.916 -> [WIFIM] Connected:
14:25:32.916 -> [WIFIM]   SSID: Me
14:25:32.916 -> [WIFIM]   IP:   192.168.225.214
14:25:32.916 -> [WIFIM]   MAC:  A8:6B:AD:10:4C:FD
14:25:32.916 -> [WIFIM]   CH:   11
14:25:32.916 -> [WIFIM]   RSSI: -70
14:25:32.962 -> [WS-Client] Websocket Version: 2.3.5
14:25:32.962 -> [WS-Client] connect ws...
14:25:32.962 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com
14:25:33.056 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com IP: 34.255.134.30
14:25:33.056 -> :ref 1
14:25:33.291 -> [WS-Client] connected to 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443.
14:25:33.291 -> [WS-Client][sendHeader] sending header...
14:25:33.291 -> [offending String op 173->199 ('GET /updat ... cket-Key: ')]
14:25:33.291 -> [offending String op 199->223 ('GET /updat ... B9ewbA==
14:25:33.291 -> ')]
14:25:33.291 -> [offending String op 223->232 ('GET /updat ... Protocol: ')]
14:25:33.291 -> [offending String op 232->249 ('GET /updat ...  arduino
14:25:33.291 -> ')]
14:25:33.291 -> [offending String op 249->287 ('GET /updat ...  file://
14:25:33.337 -> ')]
14:25:33.337 -> [offending String op 287->289 ('GET /updat ... t-Client
14:25:33.337 -> ')]
14:25:33.337 -> [WS-Client][sendHeader] handshake GET /updatedevice HTTP/1.1
14:25:33.337 -> Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443
14:25:33.337 -> Connection: Upgrade
14:25:33.337 -> Upgrade: websocket
14:25:33.337 -> Sec-WebSocket-Version: 13
14:25:33.337 -> Sec-WebSocket-Key: lb50E3bBBsUHwViZB9ewbA==
14:25:33.337 -> Sec-WebSocket-Protocol: arduino
14:25:33.337 -> Origin: file://
14:25:33.337 -> User-Agent: arduino-WebSocket-Client
14:25:33.337 -> 
14:25:33.337 -> [write] n: 289 t: 15743
14:25:33.337 -> :wr 289 0
14:25:33.337 -> :wrc 289 289 0
14:25:33.337 -> [WS-Client][sendHeader] sending header... Done (66379us).
14:25:33.572 -> :ack 289
14:25:33.572 -> :rn 370
14:25:33.572 -> :rcl pb=0x3fff13f4 sz=370
14:25:33.572 -> [WS-Client] connection lost.
14:25:33.619 -> :ur 1
14:25:33.619 -> :dsrcv 370
14:25:33.619 -> :close
14:25:33.619 -> :del
14:25:33.619 -> [WS-Client] client disconnected.
14:25:33.619 -> [WSc] Disconnected!
14:25:38.582 -> [WS-Client] connect ws...
14:25:38.582 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com
14:25:38.629 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com IP: 34.255.134.30
14:25:38.629 -> :ref 1
14:25:38.817 -> [WS-Client] connected to 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443.
14:25:38.817 -> [WS-Client][sendHeader] sending header...
14:25:38.817 -> [offending String op 173->199 ('GET /updat ... cket-Key: ')]
14:25:38.817 -> [offending String op 199->223 ('GET /updat ... /uUXYw==
14:25:38.863 -> ')]
14:25:38.863 -> [offending String op 223->232 ('GET /updat ... Protocol: ')]
14:25:38.863 -> [offending String op 232->249 ('GET /updat ...  arduino
14:25:38.863 -> ')]
14:25:38.863 -> [offending String op 249->287 ('GET /updat ...  file://
14:25:38.863 -> ')]
14:25:38.863 -> [offending String op 287->289 ('GET /updat ... t-Client
14:25:38.863 -> ')]
14:25:38.863 -> [WS-Client][sendHeader] handshake GET /updatedevice HTTP/1.1
14:25:38.863 -> Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443
14:25:38.863 -> Connection: Upgrade
14:25:38.863 -> Upgrade: websocket
14:25:38.863 -> Sec-WebSocket-Version: 13
14:25:38.863 -> Sec-WebSocket-Key: B030LbL3tyCZPhOq/uUXYw==
14:25:38.863 -> Sec-WebSocket-Protocol: arduino
14:25:38.910 -> Origin: file://
14:25:38.910 -> User-Agent: arduino-WebSocket-Client
14:25:38.910 -> 
14:25:38.910 -> [write] n: 289 t: 21285
14:25:38.910 -> :wr 289 0
14:25:38.910 -> :wrc 289 289 0
14:25:38.910 -> [WS-Client][sendHeader] sending header... Done (67388us).
14:25:39.145 -> :ack 289
14:25:39.145 -> :rn 370
14:25:39.145 -> :rcl pb=0x3fff1404 sz=370
14:25:39.145 -> [WS-Client] connection lost.
14:25:39.192 -> :ur 1
14:25:39.192 -> :dsrcv 370
14:25:39.192 -> :close
14:25:39.192 -> :del
14:25:39.192 -> [WS-Client] client disconnected.
14:25:39.192 -> [WSc] Disconnected!
14:25:39.848 -> pm open,type:2 0
14:25:44.160 -> [WS-Client] connect ws...
14:25:44.160 -> [hostByName] request IP for: 3xcls223mg.execute-api.eu-west-1.amazonaws.com
14:25:44.160 -> [hostByName] Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com IP: 34.255.134.30
14:25:44.207 -> :ref 1
14:25:44.582 -> [WS-Client] connected to 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443.
14:25:44.629 -> [WS-Client][sendHeader] sending header...
14:25:44.629 -> [offending String op 173->199 ('GET /updat ... cket-Key: ')]
14:25:44.629 -> [offending String op 199->223 ('GET /updat ... e5ODQw==
14:25:44.629 -> ')]
14:25:44.629 -> [offending String op 223->232 ('GET /updat ... Protocol: ')]
14:25:44.629 -> [offending String op 232->249 ('GET /updat ...  arduino
14:25:44.629 -> ')]
14:25:44.629 -> [offending String op 249->287 ('GET /updat ...  file://
14:25:44.629 -> ')]
14:25:44.629 -> [offending String op 287->289 ('GET /updat ... t-Client
14:25:44.629 -> ')]
14:25:44.629 -> [WS-Client][sendHeader] handshake GET /updatedevice HTTP/1.1
14:25:44.629 -> Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443
14:25:44.676 -> Connection: Upgrade
14:25:44.676 -> Upgrade: websocket
14:25:44.676 -> Sec-WebSocket-Version: 13
14:25:44.676 -> Sec-WebSocket-Key: qmd3IHQ4ReYsL1Dte5ODQw==
14:25:44.676 -> Sec-WebSocket-Protocol: arduino
14:25:44.676 -> Origin: file://
14:25:44.676 -> User-Agent: arduino-WebSocket-Client
14:25:44.676 -> 
14:25:44.676 -> [write] n: 289 t: 27066
14:25:44.676 -> :wr 289 0
14:25:44.676 -> :wrc 289 289 0
14:25:44.676 -> [WS-Client][sendHeader] sending header... Done (66432us).
14:25:45.098 -> :ack 289
14:25:45.098 -> :rn 370
14:25:45.098 -> :rcl pb=0x3fff1614 sz=370
14:25:45.098 -> [WS-Client] connection lost.
14:25:45.098 -> :ur 1
14:25:45.098 -> :dsrcv 370
14:25:45.098 -> :close
14:25:45.145 -> :del
14:25:45.145 -> [WS-Client] client disconnected.
14:25:45.145 -> [WSc] Disconnected!```

@harymk
Copy link
Author

harymk commented May 22, 2021

what we need inside response from server

@harymk
Copy link
Author

harymk commented May 22, 2021

[SETUP] BOOT WAIT 3...
[SETUP] BOOT WAIT 2...
[SETUP] BOOT WAIT 1...
fpm close 3 
mode : sta(d8:bf:c0:11:31:96)
add if0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 11
cnt 

connected with Mk, channel 11
dhcp client start...
ip:192.168.225.207,mask:255.255.0.0,gw:192.168.225.1
[WS-Client] Websocket Version: 2.3.5
[WS-Client] connect ws...
:ref 1
[WS-Client] connected to 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443.
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET /updatedevice HTTP/1.1
Host: 3xcls223mg.execute-api.eu-west-1.amazonaws.com:443
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: QAitfyGhb81OYaBvq6Xo6w==
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client

[write] n: 289 t: 7028
:wr 289 0
:wrc 289 289 0
[WS-Client][sendHeader] sending header... Done (34243us).
:ack 289
:rn 370
:rcl pb=0x3fff1224 sz=370
[WS-Client] connection lost.
:ur 1
:dsrcv 370
:close
:del
[WS-Client] client disconnected.
[WSc] Disconnected!```

@Links2004
Copy link
Owner

the web socket request header is send to the server, but your server is closing the connection.
take a look at the server logs.

@harymk
Copy link
Author

harymk commented May 22, 2021

    Host: '3xcls223mg.execute-api.eu-west-1.amazonaws.com',
    'x-api-key': '',
    'X-Forwarded-For': '',
    'x-restapi': ''
  },
  multiValueHeaders: {
    Host: [ '3xcls223mg.execute-api.eu-west-1.amazonaws.com' ],
    'x-api-key': [ '' ],
    'X-Forwarded-For': [ '' ],
    'x-restapi': [ '' ]
  },
  requestContext: {
    routeKey: '$disconnect',
    disconnectStatusCode: 1006,
    eventType: 'DISCONNECT',
    extendedRequestId: 'fvLJ9EMQDoEFXSw=',
    requestTime: '22/May/2021:15:38:26 +0000',
    messageDirection: 'IN',
    disconnectReason: 'Connection Closed Abnormally',
    stage: 'updatedevice',
    connectedAt: 1621697605538,
    requestTimeEpoch: 1621697906882,
    identity: {
      userAgent: 'arduino-WebSocket-Client',
      sourceIp: '137.97.106.23'
    },
    requestId: 'fvLJ9EMQDoEFXSw=',
    domainName: '3xcls223mg.execute-api.eu-west-1.amazonaws.com',
    connectionId: 'fvKa4d88joECFDw=',
    apiId: '3xcls223mg'
  },
  isBase64Encoded: false
}``` only disconnect log 

@harymk
Copy link
Author

harymk commented May 22, 2021

its aws api websocket wss://3xcls223mg.execute-api.eu-west-1.amazonaws.com/updatedevice

@Links2004
Copy link
Owner

are you using webSocket.beginSSL or webSocket.begin?

@harymk
Copy link
Author

harymk commented May 22, 2021

webSocket.begin

@harymk
Copy link
Author

harymk commented May 22, 2021

webSocket.begin("3xcls223mg.execute-api.eu-west-1.amazonaws.com", 443, "/updatedevice");

is that ok?

@harymk
Copy link
Author

harymk commented May 22, 2021

what response we need from server statusCode: 200, headers: { "Sec-WebSocket-Protocol" : "arduino" } am only using this is that ok?

@harymk harymk closed this as completed May 23, 2021
@harymk harymk reopened this May 23, 2021
@harymk
Copy link
Author

harymk commented May 23, 2021

Hello

@Links2004
Copy link
Owner

wss --> https --> webSocket.beginSSL
ws --> http --> webSocket.begin

@harymk
Copy link
Author

harymk commented May 23, 2021

I checked but after connection esp restaring

@harymk
Copy link
Author

harymk commented May 23, 2021

[SETUP] BOOT WAIT 3...
[SETUP] BOOT WAIT 2...
[SETUP] BOOT WAIT 1...
[WSc] Connected to url: /updatedevice
[WSc] get text: {"message":"Probably"}
[WSc] get text: Connected```

Thanks its working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants