You are not logged in.
Pages: 1
Hello ab,
I would like to share some thoughts about WebSocketServer, as I am about to run it on production server, and face some problems which I am workarounding but is better to be handled by the framework itself.
1. New callbacks for OnPing and OnPong frames. Let us define our App logic around this mechanism. Very handy when measuring connection speed, as sending messages over slow connections easy fills http.sys kernel side entity cache. When it happen it closes underlying TCP connection, which leads to problems to the web socket client and THttpApiWebSocketServer itself. Pinging client and waiting for pong response every XXX kb transferred until we continue with transfers is an easy fix.
2. Better handle Http.ReceiveRequestEntityBody and Http.SendResponseEntityBody for errors, eg. ERROR_NETNAME_DELETED for read, which often precedes ERROR_CONNECTION_INVALID for write, when underlying tcp connection broke.
3. Better synchronization of TSynWebSocketGuard actions. When I used to run it, I often end with application process being terminated with "Faulting module name: KERNELBASE.dll". Further investigation shows:
STACK_TEXT:
KERNELBASE!RaiseException+0x68
websocket!ReportFatalException+0x74
websocket!WebSocket_invalid_object_handle_fatal_error+0x32
websocket!WebSocket::VerifyCookie+0x1c
websocket!WebSocketSend+0x24
Debugging shows it happens when guard close the connection and handle to the websocket is set to nil, but TSynThreadPoolHttpApiWebSocketServer.Task still try to do number of WebSocketAPI operations over a nil handle
4. If possible some mechanism to wait until http drain its response entity body, like socket flush
Will stop here
Thanks.
Offline
@chapa - me and Vadim contribute THttpApiWebSocketServer to mORMot, but as far as I understand it not used by mORMot framework itself. So it just a "stay-alone" implementation.
We used it in production for several years to send notifications to browser clients (one way). But after migration to Linux as a primary OS for our solutions we do not use it anymore. Since current thread based implementation of TWebSocketServer don't feet our needs (1000 - 10000 connections) we switch to RabbitMQ with websocket plugin for our notifications task (btw it give for us a message persistent layer).
So, (may be @ab correct me..) - contribution is welcome.
Offline
@chapa - me and Vadim contribute THttpApiWebSocketServer to mORMot, but as far as I understand it not used by mORMot framework itself. So it just a "stay-alone" implementation.
We used it in production for several years to send notifications to browser clients (one way). But after migration to Linux as a primary OS for our solutions we do not use it anymore. Since current thread based implementation of TWebSocketServer don't feet our needs (1000 - 10000 connections) we switch to RabbitMQ with websocket plugin for our notifications task (btw it give for us a message persistent layer).
So, (may be @ab correct me..) - contribution is welcome.
Is there any good opensource FPC/Delphi library for RabbitMQ other then what is available commercially ?
Offline
we use this binding to C library
Offline
@mvp
Looking at http.sys websocket implementation, I feel it very close and native to me, as I remember well back on 2013, when I fight making it work. I would like to give it a try with mormot, and already had adopted it, now serving real-time communication between internal services stable, at extremely high rate and no latency. So, thank you very much for your and Vadim contribution, now it is not sitting in the corner
Speaking about it, I was always wondering about migrating on Linux. Recently was reading a lot about RabbitMQ also.
But I did not felt comfortable going this way. I am stuck with Window's SRWLock, ConditionVariables, Queues. Will have hard time moving all of them, and to be honest, I am very satisfied about their performance.
I am very keen to ask you about your impression, pros and cons migrating services to linux, and rabbitmq performance itself in terms of throughput and latency? I am sure you put it on a stress
Last edited by chapa (2019-03-02 09:52:47)
Offline
SRWLock exists in posix threads, so this is not a problem
thread_rwlock_rdlock(p);
thread_rwlock_unlock(p);
...
thread_rwlock_wrlock(p);
thread_rwlock_unlock(p);
But I don't know about it performance.
RabbitMQ for example used in World Of Tank, so I think it's performance is enough for most task. We use in one of our hi-load IoT project w/o problem. Now we plane to use it as a service bus for integration.
Our goal of migration to Linux not in performance and even not in cost but in security, deployment and maintaining. From this POW it's nothing to compare Linux and Windows. It's like compare BMW & Lada Kalina And after 1 year with Linux I fully agree with nginx author - see the last paragraph in this article
Last edited by mpv (2019-03-02 19:03:04)
Offline
@pvn0 search for "delphi amqp".
Kbmmw also has an Amqp 0.91 library.
Offline
we switch to RabbitMQ with websocket plugin for our notifications task
Which websocket plugin? (Web-stomp?) It's reliable? Any experience to share?
Last edited by emk (2019-03-03 13:37:19)
Offline
Pages: 1