Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

WebSocket implementation is buggy or bad documented.

Aperta
#138 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@briot ci sta già lavorando.

Dal 25/6/2020.

  • #159 di @briot — aperta

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

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AdaCore/aws

Tutte le issue di AdaCore/aws

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.