Home AMX User Forum AMX General Discussion

Cometd/Bayeux Protocol

Anyone got and example of a cometd handshake over an http transport? I open a socket send my header and handshake request but always get an error saying no bayeux message found so I thinking the syntax of my handshake request is wrong so if anyone has a working example I'd appreciate some help.

Comments

  • viningvining Posts: 4,368
    Well I found my mistakes this morning and the following client strings provide a successful response from the server:
    cJSON_TestStr = [{"channel":"/meta/handshake","ext":{"mac":"00:04:20:23:a7:6d","rev":"7.7.1 r0","uuid":"null"},"supportedConnectionTypes":["long-polling","streaming"],"version":"1.0"}]
    

    Once the port is opened I send:
    SEND_STRING dvJSON,"'POST /cometd HTTP/1.1',STR_CRLF"; 
    SEND_STRING dvJSON,"'Host: ',sJSON.sPlayer.cIP,':',itoa(sJSON.sPlayer.nPort),STR_CRLF";
    SEND_STRING dvJSON,"'Referer: http://',sJSON.sPlayer.cIP,':',itoa(sJSON.sPlayer.nPort),'/',STR_CRLF";
    SEND_STRING dvJSON,"'Cache-Control: no-cache',STR_CRLF";
    SEND_STRING dvJSON,"'Pragma: no-cache',STR_CRLF";
    SEND_STRING dvJSON,"'Content-Length: ',itoa(length_string(cJSON_TestStr)),STR_CRLF";
    SEND_STRING dvJSON,"'Content-Type: application/json',STR_CRLF";
    SEND_STRING dvJSON,"STR_CRLF";
    SEND_STRING dvJSON,"cJSON_TestStr,STR_CRLF";
    

    The following is received in debug:
    Line      8 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, HEADER-[ HTTP/1.1 200 OK$0D$0AServer: Logitech Media Server (7.8.0 - 1395395852)$0D$0ACache-Control: no-cache$0D$0APragma: no-cache$0D$0AContent-Leng
    Line      9 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-2], th: 203$0D$0AContent-Type: application/json$0D$0AExpires: -1$0D$0AX-Time-To-Serve: 0.00932717323303223$0D$0A$0D$0A ] :DEBUG<1018>
    Line     10 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ HTTP/1.1 200 OK$0D$0A ] :DEBUG<1025>
    Line     11 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Server: Logitech Media Server (7.8.0 - 1395395852)$0D$0A ] :DEBUG<1025>
    Line     12 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Cache-Control: no-cache$0D$0A ] :DEBUG<1025>
    Line     13 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, Unexpected STRSEG-[ Cache-Control: no-cache ] :DEBUG<1063>
    Line     14 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Pragma: no-cache$0D$0A ] :DEBUG<1025>
    Line     15 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, Unexpected STRSEG-[ Pragma: no-cache ] :DEBUG<1063>
    Line     16 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Content-Length: 203$0D$0A ] :DEBUG<1025>
    Line     17 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Content-Type: application/json$0D$0A ] :DEBUG<1025>
    Line     18 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ Expires: -1$0D$0A ] :DEBUG<1025>
    Line     19 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, Unexpected STRSEG-[ Expires: -1 ] :DEBUG<1063>
    Line     20 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ X-Time-To-Serve: 0.00932717323303223$0D$0A ] :DEBUG<1025>
    Line     21 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, STRSEG-[ $0D$0A ] :DEBUG<1025>
    Line     22 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], RX, BODY-[ [{"channel":"/meta/handshake","advice":{"timeout":60000,"interval":0,"reconnect":"retry"},"supportedConnectionTypes":["long-polling","streaming"],
    Line     23 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-2], "clientId":"257f4af2","successful":true,"version":"1.0"}] ] :DEBUG<3721>
    Line     24 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ {"channel":"/meta/handshake","advice":{"timeout":60000,"interval":0,"reconnect":"retry"},"supportedConnectionTypes":["long-polling","s
    Line     25 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-2], treaming"],"clientId":"257f4af2","successful":true,"version":"1.0"}] ] :DEBUG<3484>
    Line     26 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ {"channel":"/meta/handshake ] :DEBUG<881>
    Line     27 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ channel ], val-[ /meta/handshake ] :DEBUG<1001>
    Line     28 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ ,"advice":{"timeout":60000,"interval":0,"reconnect":"retry"},"supportedConnectionTypes":["long-polling","streaming"],"clientId":"257f4
    Line     29 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-2], af2","successful":true,"version":"1.0"}] ] :DEBUG<3484>
    Line     30 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ ,"advice":{"timeout":60000,"interval":0,"reconnect":"retry"} ] :DEBUG<881>
    Line     31 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ advice ], val-[ {"timeout":60000,"interval":0,"reconnect":"retry"} ] :DEBUG<1001>
    Line     32 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ ,"supportedConnectionTypes":["long-polling","streaming"],"clientId":"257f4af2","successful":true,"version":"1.0"}] ] :DEBUG<3484>
    Line     33 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ ,"supportedConnectionTypes":["long-polling","streaming"] ] :DEBUG<881>
    Line     34 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ supportedConnectionTypes ], val-[ ["long-polling","streaming"] ] :DEBUG<1001>
    Line     35 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ ,"clientId":"257f4af2","successful":true,"version":"1.0"}] ] :DEBUG<3484>
    Line     36 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ ,"clientId":"257f4af2 ] :DEBUG<881>
    Line     37 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ clientId ], val-[ 257f4af2 ] :DEBUG<1001>
    Line     38 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ ,"successful":true,"version":"1.0"}] ] :DEBUG<3484>
    Line     39 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ ,"successful":true ] :DEBUG<881>
    Line     40 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ successful ], val-[ true ] :DEBUG<1001>
    Line     41 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ReturnRawTag, rx str-[ "version":"1.0"}] ] :DEBUG<3484>
    Line     42 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, StrSeg-[ "version":"1.0 ] :DEBUG<881>
    Line     43 (09:28:29)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, tag-[ version ], val-[ 1.0 ] :DEBUG<1001>
    Line     44 (09:28:30)::  JSON_MOD-[1]:DEBUG:[L-1], ParseBody, ParseBody Complete! :DEBUG<1007>
    
Sign In or Register to comment.