Hello Hugo,
thank you for this fantastic, stable, and secure Webserver.
I'm trying to get the Websocket interface of Hiawatha working, but without success now.
Possibly, I do not understand how Hiawatha supports this kind of protocol, and the manual is not very clear on this topic.
Within my virtual host section, I've added "WebSocket = wss://127.0.0.1:5000 /api/websocket 15".
On my Linux embedded machine, I've created and started a server process listening on TCP port 5000.
The client application is an AngularJS application using the Websocket library provided by https://github.com/AngularClass/angular-websocket. My client application and related Ajax requests over HTTPS work properly so far
. Furthermore, I can see the HTTPS GET request header to /api/websocket containing some Websocket related header fields, when the websocket connection should be established
Network traffic as seen by Firefox dev-tools:
Request Header:
Host: 192.168.51.33
User-Agent: "Mozilla/5.0 (X11; Ubuntu; Linux...."
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: "de-de,en;q=0.8,pl;q=0.5,en-us;q=0.3"
Accept-Encoding: "gzip,deflate"
Sec-WebSocket-Version: "13"
Origin: "https://192.168.51.33"
Sec-Websocket-Key: "EurnA7QzUTK9AV..."
Connection: "keep-alive,Upgrade"
Pragma: "no-cache"
Cache-Control: "no-cache"
Upgrade: "websocket"
At this time I can see the client connection on my listening port 5000.
Calling socket::accept to accept the client connection on port 5000 is successful, but does not lead Hiawatha to send an appropriate HTTPS response header. The client request is still pending (Firefox dev-tools).
Now, if I send some arbitrary data (e.g. Hello world) through the connected socket on port 5000, the client gets a "500 Internal Server Error" message.
Within the hiawatha-error.gui.log file I see following messages:
192.168.51.32|Fri 06 Oct 2017 07:08:12 +0000|TLS handshake error with websocket
192.168.51.32|Fri 06 Oct 2017 07:08:31 +0000|error connecting to websocket
The TLS connection/handshake works properly with "normal" Ajax requests and JSON payload, but not with websocket?
The server configuration:
ServerId = www-data
ConnectionsTotal = 32
ConnectionsPerIP = 32
MaxUrlLength = 1000
MinTLSversion = TLS1.1
ThreadPoolSize = 10
WorkDirectory = /usr/local/var/ram/hiawatha
SystemLogFile = /var/log/hiawatha.log
ErrorLogFile = /var/log/hiawatha-error.log
AccessLogFile = /dev/null
Hostname = 127.0.0.1
WebsiteRoot = /usr/local/var/www
StartFile = index.html
Binding {
BindingId = SERVICE
Port = 443
Interface = 0.0.0.0
MaxKeepAlive = 60
TimeForRequest = 5,30
TLScertFile = /mnt/config/test.pem
MaxRequestSize = 20480
MaxUploadSize = 25
EnableAlter = yes
}
FastCGIserver {
FastCGIid = fcgi0
ConnectTo = 127.0.0.1:65530
}
UrlToolkit {
ToolkitID = GUI
RequestURI isfile Return
Match ^/api/.* UseFastCGI fcgi0
}
VirtualHost {
RequireBinding = SERVICE
Hostname = *
RequireTLS = yes
PreventXSS = yes
WebsiteRoot = /usr/local/var/www
StartFile = index.html
TimeForCGI = 300
UseToolkit = GUI
AlterList = allow all
AlterMode = 666
FollowSymlinks = yes
WebSocket = wss://127.0.0.1:5000 /api/websocket 15
AccessLogfile = /dev/null
ErrorLogfile = /var/log/hiawatha-error.gui.log
}
Any help and clarification on this topic would be greatly appreciated. Thank you.
Regards,
Carsten