Comments (9)
Of course. :) If you create WebSocket endpoints with Pushpin, then any WebSocket clients can connect to them, including the JavaScript WebSocket object in the browser.
Creating WebSocket endpoints requires server development though, to react to Pushpin's proxied events. Did you write any such code yet? If not, you can try Pushpin's test mode, which lets you connect and publish without having to write backend code.
First make sure your routes
file is routing to the internal test service (this is the default out of the box):
* test
The test mode has a WebSocket endpoint living at /ws
that automatically subscribes to a channel called test
. Connect to it:
var ws = new WebSocket('ws://localhost:7999/ws');
ws.onmessage = function (message) {
console.log(message.data);
};
Then from a terminal, you can publish using the pushpin-publish
command line tool:
pushpin-publish test "hello world"
Please note that in a real application you would write backend code instead of using the test mode.
from pushpin.
wow thats great
i had no idea about this
thanks
from pushpin.
sorry to reopen this but i am getting some errors
i botted a docker pushpin container and i created a ws server in GO server, with javascript ws i tried to connect to the go server
but the ws connection is dropped
WebSocket connection to 'ws://localhost:8080/' failed: Error during WebSocket handshake: 'Sec-WebSocket-Extensions' header value is rejected by the parser: grip; message-prefix=""
and i get this error on the server
http: panic serving [::1]:5307: Publish failed with: Post 0.0.0.0:5561/publish/: unsupported protocol scheme ""
goroutine 5 [running]:
net/http.(*conn).serve.func1(0xc08204a100)
C:/Go/src/net/http/server.go:1389 +0xc8
panic(0x6c6f20, 0xc0820b21a0)
C:/Go/src/runtime/panic.go:426 +0x4f7
main.GripWebSocketHandler(0x2885760, 0xc082033790, 0xc0820a61c0)
F:/projects/go/pushpin/main.go:40 +0x87f
net/http.HandlerFunc.ServeHTTP(0x85f290, 0x2885760, 0xc082033790, 0xc0820a61c0)
C:/Go/src/net/http/server.go:1618 +0x41
net/http.(*ServeMux).ServeHTTP(0xc082058780, 0x2885760, 0xc082033790, 0xc0820a61c0)
C:/Go/src/net/http/server.go:1910 +0x184
net/http.serverHandler.ServeHTTP(0xc08204a080, 0x2885760, 0xc082033790, 0xc0820a61c0)
C:/Go/src/net/http/server.go:2081 +0x1a5
net/http.(*conn).serve(0xc08204a100)
C:/Go/src/net/http/server.go:1472 +0xf35
created by net/http.(*Server).Serve
C:/Go/src/net/http/server.go:2137 +0x455
apparently i mixd things up, ws://localhost:7999/ was the right client port
but now i am getting
WebSocket connection to 'ws://localhost:7999/channel' failed: Error during WebSocket handshake: Unexpected response code: 502
or
Error while proxying to origin. while accessing with HTTP get request which i think shows me that its the right url/port
from pushpin.
What does your routes
file look like? Should Pushpin speak to your backend server using HTTP or WebSocket? (you mention a "ws server in GO" so I just want to be sure).
from pushpin.
hello
i have not yet touched the routes file because there were no instructions on the docker image, i am booting a linode instance and will test directly again
from pushpin.
so what you described above with * test
, should work without a server?
i am unable to get that result from the docker image
var ws = new WebSocket('ws://localhost:7999/ws');
ws.onmessage = function (message) {
console.log(message.data);
};
WebSocket connection to 'ws://localhost:7999/ws' failed: Error during WebSocket handshake: Unexpected response code: 502
from pushpin.
good news, directly from a linode instance works.
i am maybe doing something wrong with docker, looks like this
PORTS NAMES
5560-5563/tcp, 0.0.0.0:7999->7999/tcp pushpin
i will investigate further
from pushpin.
The docker image routes to app:8080
instead of the internal test service. See the Dockerfile. You can set the target
environment variable when running the image to have it route somewhere else.
from pushpin.
that makes sense
thanks a bunch
from pushpin.
Related Issues (20)
- Respond to websocket pings HOT 1
- Websocket-over-HTTP content-type charset HOT 2
- unable to install pushpin via Dockerfile [dl.bintray.com is forbidden] HOT 1
- intergate a small backend server with existing pushpin Docker file HOT 3
- Schema of the architecture of pushpin ? HOT 1
- Error 502 when proxy forwarding from nginx HOT 1
- Multi-arch docker image with M1 support HOT 3
- Pushpin installation from JFrog's DEB repo times out HOT 1
- Not able to publish messages via 0MQ from backend server HOT 4
- Memory increasing when clients connect but doesn't free up when they disconnect HOT 5
- 1% of traffic receives 502
- How to log connection Id while making a http call to Backend service? HOT 1
- tp://localhost:5561/publish/ by default
- Support qt6 HOT 1
- issue while installing pushpin on rhel-8, any additional repository has to configure ? HOT 1
- Pushpin
- Fast
- Third party Pushpin hosts? HOT 1
- HTTP Custom
- Memory leak after upgrade to 1.38.0 HOT 5
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 pushpin.