Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alash3al/wsify
Just a tiny, simple and real-time self-hosted pub/sub messaging service
https://github.com/alash3al/wsify
backend go golang pub pubsub pusher realtime realtime-messaging redis-channel tiny topic webhook websocket-service websockets
Last synced: 14 days ago
JSON representation
Just a tiny, simple and real-time self-hosted pub/sub messaging service
- Host: GitHub
- URL: https://github.com/alash3al/wsify
- Owner: alash3al
- License: mit
- Created: 2018-01-24T10:59:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T11:40:35.000Z (2 months ago)
- Last Synced: 2024-04-06T12:33:09.110Z (2 months ago)
- Topics: backend, go, golang, pub, pubsub, pusher, realtime, realtime-messaging, redis-channel, tiny, topic, webhook, websocket-service, websockets
- Language: Go
- Homepage:
- Size: 924 KB
- Stars: 516
- Watchers: 20
- Forks: 54
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Lists
- my-awesome-stars - wsify - time self-hosted pub/sub messaging service | alash3al | 508 | (Go)
- awesome-stars - alash3al/wsify - Just a tiny, simple and real-time self-hosted pub/sub messaging service (Go)
- starred-awesome - wsify - Just a tiny, simple and real-time self-hosted pub/sub messaging service (Go)
- awesome-stars - wsify - Just a tiny, simple and real-time self-hosted pub/sub messaging service (Go)
- awesome-stars - alash3al/wsify - Just a tiny, simple and real-time self-hosted pub/sub messaging service (Go)
- awesome - wsify - Just a tiny, simple and real-time self-hosted pub/sub messaging service (Go)
- awesome-stars - alash3al/wsify - A very simple general purpose websocket server that does the job (golang)
- awesome-golang-repositories - wsify - time self-hosted pub/sub messaging service (Repositories)
README
Websocketify (wsify) v2.0 [![StackShare](https://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](https://stackshare.io/alash3al/wsify)
=========================
> Just a tiny, simple and realtime pub/sub messaging service![Quick Demo](https://i.imgur.com/jxyejg0.gif)
Why
====
> I wanted to create a tiny solution that can replace `pusher` and similar services and learning more about the realtime world, so I dispatched this project.Features
================
- No dependencies, just a single binary !
- Light and Tiny.
- Event-Driven Design `webhooks`.
- A client can listen on any resource.
- You control whether a client is allowed to `connect`, `subscribe`, `unsubscribe` using any programming language !.
- A client defines itself using `key` via the url query param i.e `?key=123`.
- Send messages to only certain users.Installation
==============
- **Docker ?** > `docker run --network host alash3al/wsify -listen :8080 -webhook "http://localhost/wsify.php"`
- **Binary ?** > goto the [releases](https://github.com/alash3al/wsify/releases) page and download yours.
- **From Source ?** > `go get -u github.com/alash3al/wsify`Questions
==========### (1)- How can a client/device connect to the websocket service?
> by simply connecting to the following endpoint `ws://your.wsify.service:port/subscribe`### (2)- How can a client subscribe to a certain channel(s)/topic(s)?
> after connecting to the main websocket service `/subscribe`, you can send a simple json payload `commands` to ask wsify to `subscribe`/`unsubscribe` you to/from any channel/topic you want!### (3)- What is the commands format?
>
```json
{
"action": "subscribe",
"value": "testchan"
}```
### (4)- Can I control the client command so I can allow/disallow certain users?
> Yes, each client can define itself using a query param `?key=client1`, this key will be passed to the `webhook` endpoint
as well as the event being executed, and here is the event format:
```javascript
{
// one of the following: connect|subscribe|unsubscribe|disconnect
"action": "subscribe",// the channel if provided
"value": "testchan"
}
```### (5)- How can I publish message to i.e `testchan`?
> Just a post request to `/publish` with the following format:
```javascript
{
// the channel you want to publish to
"channel": "testchan",// the data to be send (any format)
"payload": "testchan",// array of clients "keys" (if you want certain clients only to receive the message)
"to": []
}
```
i.e
```bash
curl -X POST \
-H "Content-Type: application/json" \
-d '{"payload": "hi from the terminal", "channel": "testchan"}' \
http://localhost:4040/publish
```### (6)- Can I skip the webhook events for testing?
> Yes, `wsify --events=""` empty events means "NO WEBHOOK, WSIFY!"### (7)- How can I secure the publish endpoint, so no one except me can publish ?!!
> Easy :), Just change the endpoint to something more secure and hard to guess it is an alternative to access tokens .. etc, `wsify --publish="/broadcasteiru6chefoh1Yee0MohJ2um5eepaephies3zonai0Cae7quaeb"`### (8)- What about other options?
> `wsify --help` will help you !### (9)- What is the websocket client used in demos?
> [Simple Websocket Client](https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo)### (10)- How I can use it over SSl/TLS with Nginx?
> You can use proxy, add this lines on your Nginx configration
```
location /websocket/subscribe {
proxy_pass http://localhost:4040/subscribe;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
```
Now you can call websocket by `wss://yourdomain.com/websocket/subscribe`![Quick Demo2](https://i.imgur.com/f8xVwJU.gif)
Author
=============
This project has been created by [Mohamed Al Ashaal](http://github.com/alash3al) a Crazy Gopher ^^!Contribution
=============
- Fork the Repo
- Create a feature branch
- Push your changes to the created branch
- Create a pull request.License
=============
Wsify is open-sourced software licensed under the [MIT License](LICENSE).