Comments (4)
Hi,
I tried to reproduce your problem:
import ReconnectingWebsocket from "reconnecting-websocket";
import WebSocket from "ws";
const rws = new ReconnectingWebsocket("ws://lokalhost:8080", undefined, {WebSocket});
rws.addEventListener("error", () => {
console.log("error");
});
This works as expected.
Can you please send a snippet where your issue is reproduced? More details about the library version, environment, etc, would be helpful
from reconnecting-websocket.
The error was reproduced:
<!DOCTYPE html>
<html>
<head>
<title>Reconnecting WS</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Open console and send a message</h1>
<pre>echo.send('oohhyeahh!!')</pre>
<script type="module">
import ReconnectingWebSocket from 'https://unpkg.com/[email protected]/dist/reconnecting-websocket.mjs'
class Echo {
constructor() {
// Fail
this.ws = new ReconnectingWebSocket('wss://echo.websocket.org')
// Works
// this.ws = new WebSocket('wss://echo.websocket.org')
this.ws.addEventListener('open', this)
this.ws.addEventListener('message', this)
this.ws.addEventListener('close', this)
this.ws.addEventListener('error', this)
}
send(v = 'ulala') {
this.ws.send(v)
}
onopen() {
console.log('open')
this.ws.send('Hello echoooo...')
}
onmessage(event) {
console.log('message echo --->', event.data)
}
onclose() {
console.log('close')
}
onerror() {
console.log('error')
}
handleEvent(event) {
if (typeof this[`on${event.type}`] === 'function') {
this[`on${event.type}`](event)
}
}
}
window.echo = new Echo()
</script>
</body>
</html>
from reconnecting-websocket.
@lagden Thanks for reporting! Event handlers were not supporting objects with handleEvent
from reconnecting-websocket.
@lagden fixed in latest release
@ezraroda closing issue because I was unable to reproduce your problem.
Here is my code trying to reproduce it:
https://codesandbox.io/s/p4m2707om?expanddevtools=1
Please feel free to reopen this issue if you can reproduce it.
Thank you all for your feedback!
from reconnecting-websocket.
Related Issues (20)
- Prevented reconnect HOT 7
- Old websockets do not seem to be terminated HOT 5
- Dequeue Events from send
- does not support http headers HOT 4
- How to use "ws.once" with this library?
- Update this._url on a preexisting ReconnectingWebSocket object HOT 1
- Seems to be broken with API Gateway Websockets HOT 2
- allow passing multiple arguments to send method
- on leave session close event not fired HOT 1
- new ReconnectingWebSocket(url).url always empty string
- WebSocket reconnection fails when using it in a React Native simulator
- WebSocket was closed before the connection was established HOT 5
- Add a user callback After the minuptime check
- I cannot close a connection HOT 2
- Use native EventTarget instead of a custom implementation
- Project abandoned? HOT 5
- This expression is not constructable HOT 1
- Bug: `_disconnect` causes uncaught exception and process to crash if using `ws` library HOT 10
- Bug: `_handleError` does not bubble up actual error reason (e.g. `ECONNREFUSED`)
- Bug: `_getNextDelay` returns `0` while a socket may be reconnecting/connecting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reconnecting-websocket.