WebSocket implementation is buggy or bad documented.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Ambito
- backend, networking
Direzione di ricerca
Riproduci il problema con aws/demos/websockets sotto un debugger, quindi segui l'oggetto personalizzato attraverso aws-net-websocket-registry.adb, aws-server-http_utils.adb e aws-net.adb. Esamina i percorsi Create e Finalize e il failure in aws-net-buffered.adb:147. Il lavoro sarà completato quando il ciclo di vita WebSocket supportato sarà definito e documentato e i Sends lato server al di fuori dei callback saranno sicuri, con un caso di regressione se il progetto dispone di una posizione di test applicabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
I have a problem with Web_Socket API in AWS (server side). The AWS.Net.WebSocket has this:
function Create
(Socket : Socket_Access;
Request : AWS.Status.Data) return Object'Class
with Pre => Socket /= null;
-- Create a new instance of the WebSocket, this is used by AWS internal
-- server to create a default WebSocket if no other constructor are
-- provided. It is also needed when deriving from WebSocket.
--
-- This function must be registered via AWS.Net.WebSocket.Registry.Register
Looks like to create a custom web socket object one needs to define a function with the same profile and register it with the Register procedure. One (like me) could think that this function will be called to construct a custom web socket when a http client call an URL. AWS indeed calls this, but then it will destroy the object. So if you keep the object to send messages to the client it will raise PROTOCOL_ERRORaws-net-buffered.adb:147 access check failed with traceback like:
#5 0x00007fc950be087f in <__gnat_rcheck_CE_Access_Check> (file=..., line=...) at a-except.adb:1208
#6 0x00007fc951ce0f82 in aws.net.buffered.get_write_cache (socket=..., <get_write_cacheL>=...) at /tmp/openwrt/aws/src/core/aws-net-buffered.adb:147
#7 0x00007fc951ce2dff in aws.net.buffered.write (socket=..., item=...) at /tmp/openwrt/aws/src/core/aws-net-buffered.adb:440
#8 0x00007fc951d3cf34 in aws.net.websocket.protocol.rfc6455.send_frame_header (protocol=..., socket=..., opcd=..., data_length=..., has_mask=..., mask=...) at /tmp/openwrt/aws/src/core/aws-net-websocket-protocol-rfc6455.adb:767
#9 0x00007fc951d3c903 in aws.net.websocket.protocol.rfc6455.send (protocol=..., socket=..., data=..., from_client=...) at /tmp/openwrt/aws/src/core/aws-net-websocket-protocol-rfc6455.adb:626
#10 0x00007fc951da2a62 in aws.net.websocket.send (socket=..., message=..., is_binary=...) at /tmp/openwrt/aws/src/core/aws-net-websocket.adb:597
Property named C is reset by Finalize:
(gdb) bt
#0 aws.net.finalize (socket=...) at /home/max/net/aws/src/core/aws-net.adb:137
#1 0x00007f6a3fd143a6 in web_socket__handlers__aws_handlers__aws_web_socketDF__2 () at /home/max/net/matreshka/source/web/spikedog/aws/web_socket-handlers-aws_handlers.ads:69
#2 0x00007f6a3e7d2a34 in aws.server.http_utils.send (answer=..., http_server=..., line_index=..., c_stat=..., socket_taken=..., will_close=...) at /home/max/net/aws/src/core/aws-server-http_utils.adb:1657
#3 0x00007f6a3e7c2869 in aws.server.http_utils.answer_to_client (http_server=..., line_index=..., c_stat=..., socket_taken=..., will_close=...) at /home/max/net/aws/src/core/aws-server-http_utils.adb:400
#4 0x00007f6a3e7f5fdb in aws.server.protocol_handler (la=...) at /home/max/net/aws/src/core/aws-server-protocol_handler.adb:264
#5 0x00007f6a3e7f2e81 in aws.server.line (<_task>=...) at /home/max/net/aws/src/core/aws-server.adb:327
#6 0x00007f6a3da253f6 in system.tasking.stages.task_wrapper () from /home/max/net/gnat-gpl-2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib/libgnarl-2019.so
Try to run the example from aws/demos/websockets under debugger. The exampe tries to add its own field C and populate ith with zero:
return Object'(Net.WebSocket.Object
(Net.WebSocket.Create (Socket, Request)) with C => 0);
But when On_Open is called C has a garbage:
(gdb) print Socket.C
$3 = 538976288
(gdb) bt
#0 websock_cb.on_open (socket=..., message=...) at /home/max/net/aws/demos/websockets/websock_cb.adb:118
#1 0x00007ffff77c3d90 in aws.net.websocket.registry.watch (websocket=...) at /home/max/net/aws/src/core/aws-net-websocket-registry.adb:1514
#2 0x00007ffff7772650 in aws.net.websocket.registry.utils.watch (websocket=...) at /home/max/net/aws/src/core/aws-net-websocket-registry-utils.adb:49
#3 0x00007ffff782ce61 in aws.server.http_utils.send (answer=..., http_server=..., line_index=..., c_stat=..., socket_taken=..., will_close=...) at /home/max/net/aws/src/core/aws-server-http_utils.adb:1694
#4 0x00007ffff781c869 in aws.server.http_utils.answer_to_client (http_server=..., line_index=..., c_stat=..., socket_taken=..., will_close=...) at /home/max/net/aws/src/core/aws-server-http_utils.adb:400
#5 0x00007ffff784ffdb in aws.server.protocol_handler (la=...) at /home/max/net/aws/src/core/aws-server-protocol_handler.adb:264
#6 0x00007ffff784ce81 in aws.server.line (<_task>=...) at /home/max/net/aws/src/core/aws-server.adb:327
#7 0x00007ffff6a7f3f6 in system.tasking.stages.task_wrapper () from /home/max/net/aws/demos/websockets/debug/../../../..//gnat-gpl-2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib/libgnarl-2019.so
Could you suggest how should I create a Web_Socket object to be able to send some message from the server to the client outside of 'On_OpenandOn_Message` callback?
PS Cross-reference to matreshka issue.
- Lingua principale
- Ada
- Stelle
- 163
- Fork
- 46
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AdaCore/aws
-
Setup fails due to missing directory x86_64-pc-linux-gnu/setup/srcForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Upgrade of zlib required to solve compilation warnings due to K&R styleForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
paperclipai/paperclip#16785 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
mastra-ai/mastra#27538 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
webrecorder/warcio#209 ·