xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.18k stars 371 forks source link

Error: WebSocket is not open: readyState 2 (CLOSING) #990

Open roughnecks opened 1 year ago

roughnecks commented 1 year ago

Describe the bug I'm running the xmpp.js example code from https://github.com/xmppjs/xmpp.js/tree/main/packages/client#example and I'm getting the error in title.

Link to discussion It looks like it's solved now but I was told to file a report anyway.

Logs

node zed.js                                                       
status connecting wss://woodpeckersnest.space:5281/xmpp-websocket
status connect 
status opening 
status open <open id="28a1dc99-4fd4-4cf1-a782-f3080bbfd25d" from="woodpeckersnest.space" version="1.0" xmlns="urn:ietf:params:xml:ns:xmpp-framing" xml:lang="en"/>
IN
<stream:features xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams"><register xmlns="urn:xmpp:invite"/><register 
xmlns="urn:xmpp:ibr-token:0"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
OUT
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="SCRAM-SHA-1"><hidden xmlns="xmpp.js"/></auth>
IN
<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><hidden xmlns="xmpp.js"/></challenge>
OUT
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="SCRAM-SHA-1"><hidden xmlns="xmpp.js"/></response>
IN
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><hidden xmlns="xmpp.js"/></success>
status opening 
status open <open id="c20bd177-cdd4-473f-858d-dcfc2a2e0fdf" from="woodpeckersnest.space" version="1.0" xmlns="urn:ietf:params:xml:ns:xmpp-framing" xml:lang="en"/>
IN
<stream:features xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams"><sm xmlns="urn:xmpp:sm:2"><optional/></sm><sm xmlns="urn:xmpp:sm:3"><optional/></sm><sub xmlns="urn:xmpp:features:pre-approval"/><ver xmlns="urn:xmpp:features:rosterver"/><bind 
xmlns="urn:ietf:params:xml:ns:xmpp-bind"><required/></bind><session xmlns="urn:ietf:params:xml:ns:xmpp-session"><optional/></session><csi xmlns="urn:xmpp:csi:0"/><c ver="WzAzf8W+gZ/9y7lm1ovWoVQLO2Q=" hash="sha-1" xmlns="http://jabber.org/protocol/caps" node="http://prosody.im"/></stream:features>
OUT
<iq type="set" id="tlcnpvf2a5" xmlns="jabber:client"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>xmpp-client</resource></bind></iq>
IN
<iq id="tlcnpvf2a5" xmlns="jabber:client" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>service@woodpeckersnest.space/xmpp-client</jid></bind></iq>
OUT
<enable xmlns="urn:xmpp:sm:3" resume="true"/>
IN
<enabled max="600" id="rNh5pIH2aqqN" xmlns="urn:xmpp:sm:3" resume="true"/>
status online service@woodpeckersnest.space/xmpp-client
OUT
<presence xmlns="jabber:client"/>
OUT
<message type="chat" to="service@woodpeckersnest.space/xmpp-client" xmlns="jabber:client"><body>hello world</body></message>        
IN
<presence xmlns="jabber:client" from="service@woodpeckersnest.space/xmpp-client" xml:lang="en"><x xmlns="vcard-temp:x:update"><photo/></x></presence>
IN
<message to="service@woodpeckersnest.space/xmpp-client" from="woodpeckersnest.space" xmlns="jabber:client"><privilege xmlns="urn:xmpp:privilege:2"/></message>
IN
<presence from="roughnecks@woodpeckersnest.space" to="service@woodpeckersnest.space" type="subscribe" xmlns="jabber:client" xml:lang="en"><nick xmlns="http://jabber.org/protocol/nick">roughnecks</nick></presence>
IN
<message xml:lang="en" to="service@woodpeckersnest.space/bot" type="chat" xmlns="jabber:client" from="service@woodpeckersnest.space/bot"><body>hello world</body><stanza-id id="8DgsyMdpzLVPtcNKaYEX7fX8" xmlns="urn:xmpp:sid:0" by="service@woodpeckersnest.space"/><delay stamp="2023-06-24T11:10:25Z" xmlns="urn:xmpp:delay" from="service@woodpeckersnest.space"/><delay stamp="2023-06-24T11:10:25Z" xmlns="urn:xmpp:delay" from="woodpeckersnest.space"/></message>     
IN
<r xmlns="urn:xmpp:sm:3"/>
OUT
<presence type="unavailable" xmlns="jabber:client"/>
OUT
<presence type="unavailable" xmlns="jabber:client"/>
OUT
<a xmlns="urn:xmpp:sm:3" h="4"/>
status closing
status closing
status disconnecting
IN
<message from="service@woodpeckersnest.space/xmpp-client" to="service@woodpeckersnest.space/xmpp-client" type="chat" xmlns="jabber:client" xml:lang="en"><body>hello world</body><stanza-id id="yiq9p2SL0VfexuBm_dhIDHnH" xmlns="urn:xmpp:sid:0" by="service@woodpeckersnest.space"/></message>
/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/ws/lib/websocket.js:1097
    const err = new Error(
                ^

Error: WebSocket is not open: readyState 2 (CLOSING)
    at sendAfterClose (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/ws/lib/websocket.js:1097:17)
    at WebSocket.send (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/ws/lib/websocket.js:453:7)
    at Socket.write (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/websocket/lib/Socket.js:71:19)
    at /mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/connection/index.js:333:19
    at new Promise (<anonymous>)
    at Client.write (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/connection/index.js:325:12)
    at Client.send (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/connection/index.js:313:16)
    at Client.send (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/websocket/lib/Connection.js:22:18)
    at Client.send (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/node_modules/@xmpp/client-core/lib/Client.js:12:42)
    at Client.<anonymous> (/mnt/c/Users/roughnecks/Documents/GitHub/xmpp-ZED/zed.js:24:16)

Node.js v18.16.1

Environment Server is Prosody 0.12.3 Client is running on WSL Debian 11 (Windows 10) Node.js v18.16.1