Newer
Older
# QUIQQER Socket Server
The QUIQQER Socket module extends QUIQQER with an integrated socket server.
## Feature
- Socket Server
- Socket Client
- Socket API - other modules are able to extend the Socket Server
- based on PHP Ratchet
## Todo
- Andere Domains prüfen wegen Security Headers
- Connection Limits
- php quiqqer light header "header.php" -> wegen zu viel RAM
- https://dev.quiqqer.com/quiqqer/rabbitmqserver/-/blob/master/src/RabbitConsumer/RabbitConsumerServer
- apache virtual host ins wiki
- nginx darf mor machen
- quiqqer sessions in websocket verfügbar machen
## Developer
#### Apache install
```bash
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
sudo a2enmod proxy_wstunnel
```
#### Apache site settings:
Example for an apache site.conf
```
<VirtualHost host:443>
...
ProxyRequests off
ProxyVia on
# YOUR_HOST = replace this with your host
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://YOUR_HOST:5002/$1 [P,L]
ProxyPass /websocket http://127.0.0.1:5002/websocket
ProxyPassReverse /websocket http://127.0.0.1:5002/websocket
...
</VirtualHost>
```
#### Starting socket server
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
```bash
cd packages/quiqqer/socketserver;
php socketserver.php
```
### Get JS socket client
```js
require(['package/quiqqer/socketserver/bin/frontend/Client'], function (Client) {
// with the echo test endpoint
Client.getClient('/echo').then(function (WebSocketClient) {
WebSocketClient.onmessage = function (e) {
console.log('message', e.data);
};
WebSocketClient.onopen = function (e) {
WebSocketClient.send(JSON.stringify({
type : 'message',
message: 'HUHU'
}));
};
});
});
```
### Test Websockets via console
```bash
websocat wss://YOUR_HOST:YOUR_PORT/echo
```