Comments (6)
Hi @martinpley Do you still get this error? I've just tested it in stable Chrome/Opera — works as expected.
from wampy.js.
Feel free to reopen, if this bug still exists, but please provide more info.
from wampy.js.
Hello,
I am using Wampy v0.1 and when the connection broke, the client re-connect but does not subscribe again to the channels. I have tried to put subscriptions in the onConnect function, but I have the same behavior…
Here's some details:
var ws = new Wampy('ws://blablabla:8080');
ws.options({
reconnectInterval: 1000,
maxRetries: 999,
onConnect: function() {
console.log('onConnect()');
ws.subscribe('chat:test', function(data) {
data = JSON.parse(data);
if(typeof data.user !== 'undefined') {
$('#panel-chat ul').append('<li><strong>'+data.user+':</strong> '+data.message+'</li>');
}
else {
$('#panel-chat ul').append('<li><em>'+data.message+'</em></li>');
}
});
ws.subscribe('commands:test', function(data) {
console.log('command: '+data);
});
}
});
On the first connection, everything is ok. But if on the server side, when I shutdown the re-run the script, we can see that only connection is re-etablished, not subscriptions:
xxx@xxx:~/dev/wp-content/websockets$ php server.php
90.107.224.xxx is connected…
90.107.224.xxx has subscribed to chat:test
^C
xxx@xxx:~/dev/wp-content/websockets$ php server.php
90.107.224.xxx is connected…
[nothing more]
I don't think it's needed for this case, but the source of my server is:
<?php
namespace xxxWS;
use xxxWS\Token;
use Ratchet\ConnectionInterface as Conn;
use Ratchet\Wamp\WampServerInterface;
class xxxWS implements WampServerInterface {
public function onPublish(Conn $conn, $topic, $event, array $exclude, array $eligible) {
// Find the user name
$token = new Token($event['token']);
$topic->broadcast(json_encode(['user' => $token->getAlias(), 'message' => htmlspecialchars($event['message'])]));
}
public function onCall(Conn $conn, $id, $topic, array $params) {
echo "Call: $id\n";
$conn->callError($id, $topic, 'RPC not supported on this demo');
}
// No need to anything, since WampServer adds and removes subscribers to Topics automatically
public function onSubscribe(Conn $conn, $topic) {
echo $conn->remoteAddress." has subscribed to $topic\n";
$conn->send(json_encode(['message' => "You are now connected to the chatroom…"]));
}
public function onUnSubscribe(Conn $conn, $topic) {}
public function onOpen(Conn $conn) {
echo $conn->remoteAddress." is connected…\n";
}
public function onClose(Conn $conn) {
echo $conn->remoteAddress." has left…\n";
}
public function onError(Conn $conn, \Exception $e) {}
}
If you have any idea :)
from wampy.js.
Hi, @gdebrion! Well....instead of answers, i have a bunch of question :)
- Any reason, why do you use obsolete version 0.1.0 instead of current? Yes, it's WAMP v1. But it is obsolete too
- Why had you decided, that wampy v0.1.0 supports automatic resubscription? I don't see any mentions about it. So — No, it doesn't
- I advice to use onReconnect callback for resubscription. I think it should suite your needs.
Hope, it helps!
from wampy.js.
Good questions!
I am stuck with the server that implements only Wamp v1. There are not so many JS library with v1 support… For the automatic resubscription, you are right, I thought it was automatic.
I wll try with the onReconnect callback ;)
from wampy.js.
@gdebrion why do you stuck with WAMP v1? Even in PHP world there is already v2 implementation: https://github.com/voryx/Thruway — have a look! If you are using nginx/openresty env — have a look at my Wiola implementation. There are a lot of various implementations! My advise is — not to start playing with v1, only v2!
from wampy.js.
Related Issues (20)
- My thoughts on replacing "lightweight" with "feature-rich" HOT 3
- Are we using the contents of .eslintignore? I don't see a build/* folder anywhere HOT 1
- Some questions about "prefer-const" rule warnings... HOT 2
- Thoughts on adding Prettier Code Formatter HOT 1
- Suggestion: .getOptions() and .setOptions() HOT 2
- Crossbar tests are failing since #227 HOT 2
- NonExistRPCInvocationError is not being used anywhere HOT 1
- Add tests for when request Id is different from the one we have on the client side.
- MODULE_NOT_FOUND HOT 4
- disconnect() method never returning when onClose is set HOT 1
- Network connection interruption not detected HOT 16
- subscription key is "topic-undefined" when no options are passed HOT 1
- Feature request: Event Retention HOT 2
- Unhandled Rejection at Promise HOT 6
- Incorrect register options during automatic reregistration
- Unwrapping single result
- Merge "wampy-cra" plugin into main codebase.
- Merge "wampy-cryptosign" plugin into main codebase.
- Ability to work with different crypto libs
- End-2-End Encryption
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 wampy.js.