Comments (8)
I can verify that tomorrow!
from sockette.
How are you constructing the Sockette instance? Are you using new Sockette(...)
? Are you experiencing the same issue on other browsers, or is it only IE11?
Thanks!
from sockette.
I use Sockette with npm package
the code like blow:
`import Sockette from "sockette";
this.ws = new Sockette(url
, {
timeout: 100,
maxAttempts: 10,
},
onmessage: e => { },
onmaximum: e => {
that.ws.reconnect;
},
onerror: e => { },
onclose: e => {},
onreconnect: e => { }
});
`
the errors orrcured on the IE11 and Edge, other browsers(Chrome, Firefox, Opera) work fine.
Thanks!
from sockette.
@houyaowei Try this:
this.ws ? this.ws.close(1000) : null
Unrelated, but when the opts.maximum
is reached, Sockette quits. If you want to restart it, you need to call open
and not reconnect
because open
starts the series whereas reconnect
is a single attempt.
onmaximum: e => {
- that.ws.reconnect;
+ this.ws.open();
},
from sockette.
@lukeed I know this issue is closed, but it seems a bit concerning that the default close .close()
call throws an error in IE. Also, MDN states that specifying any code except 1000 and 3000 is illegal (in FireFox): https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes.
Could we make it so that the .close()
method simply passes along its args to the native .close()
method?
...
$.close = ws.close;
...
from sockette.
@elliotaplant Thanks, this actually matches what I had thought initially, but I changed it to 1005
at the last second. Can you re-verify for me that sending code 1000 on close works on IE and your copy of Firefox? (I don't have access to any IE)
Thanks!
from sockette.
Sending ws.close(1000)
Works on IE and Firefox for me!
I'm pretty busy right now but I could make a PR for this in January.
If you want to make the change, I think it would just be:
// src/index.js
...
- $.close = function (x, y) {
- ws.close(x || 1005, y);
- };
+ $.close = ws.close
...
from sockette.
Awesome, thank you 🙇
It cannot be your suggestion because the internal ws
changes over any given Sockette instance's lifespan. After all, the purpose of Sockette is to swap out & setup new WebSocket instances without your concern.
Plus, ws
isn't defined until $.open()
is called, whereas $.close = ws.close
would run (and $
returned) instantly
from sockette.
Related Issues (20)
- Disable reconnect programmatically HOT 15
- Access underlying socket object HOT 3
- SCRIPT5022: SecurityError in IE11 HOT 1
- onerror not returning code HOT 2
- ws.close should clear pending setTimeout HOT 1
- Still in CONNECTING state HOT 1
- Still reconnecting after close() HOT 5
- didunmount
- Bump npm version to include #48 HOT 1
- Able to detect network lost? HOT 1
- Possible to get WebSocket instance? HOT 1
- How to get error code HOT 1
- When I close the connection, it doesn't send queryStringParameters HOT 1
- Socket connection code choices HOT 2
- [Feature] Ability to set url before reconnecting HOT 1
- Automatically split & re-combine messages over a certain size HOT 5
- Increment timeout HOT 2
- Sockette.close can unexpectedly clear other timeouts/intervals
- project status? HOT 2
- Put an option to always reconnect, no matter what
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 sockette.