abhishiv / pusher-lite Goto Github PK
View Code? Open in Web Editor NEWIsomorphic pusher client
License: MIT License
Isomorphic pusher client
License: MIT License
There is assumption that message payload is JSON:
https://github.com/abhishiv/pusher-node-client/blob/master/lib/pusher-node-client.coffee#L117
Error I getting is:
SyntaxError: Unexpected number
at Object.parse (native)
at PusherClient.recieveMessage (/home/xxx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:175:51)
at PusherClient.recieveMessage (/home/xx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:6:61)
at WebSocketConnection.<anonymous> (/home/xxx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:140:24)
at WebSocketConnection.emit (events.js:95:17)
at WebSocketConnection.processFrame (/home/xxx/local/node/lib/node_modules/pusher-node-client/node_modules/websocket/lib/WebSocketConnection.js:356:26)
at WebSocketConnection.handleSocketData (/home/xxx/local/node/lib/node_modules/pusher-node-client/node_modules/websocket/lib/WebSocketConnection.js:205:14)
at CleartextStream.emit (events.js:95:17)
at CleartextStream.<anonymous> (_stream_readable.js:764:14)
at CleartextStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at _stream_readable.js:419:7
at process._tickCallback (node.js:419:13)
In my case payload is just a string, not a valid JSON.
The payload is a strings like "00012345|0006789".
The error is:
JSON.parse("00012345|0006789")
SyntaxError: Unexpected number
at Object.parse (native)
at repl:1:7
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.emit (events.js:98:17)
One solution is to add additional argument to channel.subscribe function, which will be indicating that there is no need to treat message payloads as JSON.
Hi there!
I'm using this library to communicate with Pusher from a Mac server. Unfortunately, when the server goes to sleep and is woken back up, the resetActivityCheck
method calls its waitingTimeout
. This wouldn't be a big deal, except the waitingTimeout
doesn't actually seem to disconnect; it only unsubscribes from the connected channels. Here's the relevant code (from lib/pusher-node-client.coffee
):
@waitingTimeout = setTimeout(
() =>
console.log "disconnecting because of inactivity at #{(new Date).toLocaleTimeString()}"
_(@channels).each (channel) =>
@unsubscribe channel.channel_name, channel.channel_data
console.log "connetcing again at #{(new Date).toLocaleTimeString()}"
if @connection.state isnt "open"
@connect()
30000
)
Is this intended behavior? If so, it would probably make sense to emit another event, so consumer code can know it should attempt to reconnect to any appropriate channels. If you'd like, I can make this change and submit a PR, or you can let me know if there's another solution you'd like implemented.
Thanks!
-paul
Hello
following pusher API documentation, we can set authentication endpoint for presence- and private- channels. Maybe I overlooked ability to set it when reviewing code, but I did not found it.
Cheers
Michael
Could you please add proxy support.
To proxy websockets I'm using faye-websocket with the following options {proxy:{ origin: wsProxyUrl},ping: XX}.
I guess for pure websockets the implementation is difficult.
just using subscribe - cant work as connection is never defined as a property of the object anywhere in the codebase.
library has been unmaintained for years, no surprise it was unfinished - pathetic its listed officially by Pusher.com
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.