sgcWebSocket Exception working with Arduino lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- negagen · 2018-06-15 05:17 Hi guys, well the topic is this i'm trying to receive messages on plain text from an arduino through websockets, i made the server with sgcWebSockets, and i'm using the websockets client library that the arduino IDE let you install, the problem is this trying only connect to the websokect server i made i get this error: Error Protocol: arduino  not supported. i tried to solve this using a subprotocol with the example code that sgcWebSocket let you use: unit ProtocoloArduino; interface {$I sgcVer.inc} {$IFDEF SGC_PROTOCOLS} uses   sgcWebSocket_Protocol_Base_Server, Classes, sgcWebSocket_Classes; type   TsgcWSProtocol_Arduino = class(TsgcWSProtocol_Server_Base)   { from TsgcWSComponent }   protected    procedure DoEventConnect(aConnection: TsgcWSConnection); override;    procedure DoEventMessage(aConnection: TsgcWSConnection; const Text: string); override;    procedure DoEventDisconnect(aConnection: TsgcWSConnection; Code: Integer); override;   { from TsgcWSComponent }   public    constructor Create(aOwner: TComponent); override;   end; {$ENDIF} implementation {$IFDEF SGC_PROTOCOLS} constructor TsgcWSProtocol_Arduino.Create(aOwner:TComponent); begin   inherited;   // ... here add your protocol name   FProtocol := 'arduino'; end; procedure TsgcWSProtocol_Arduino.DoEventConnect(aConnection:TsgcWSConnection); begin   inherited;   // ... add your own code when a client connects to server end; procedure TsgcWSProtocol_Arduino.DoEventDisconnect(aConnection: TsgcWSConnection; Code: Integer); begin   // ... add your own code when a client disconnects from server   inherited; end; procedure TsgcWSProtocol_Arduino.DoEventMessage(aConnection: TsgcWSConnection; const Text: string); begin   inherited;   // ... process messages received from clients   // ... you can answer to client using   WriteData(aConnection.Guid, 'your message');   // ... you can send a message to all clients using   BroadCast('your message'); end; {$ENDIF} end. but i didn't work registering this protocol either, looking in the source code of sgcWebSocket the exception is throw here: ..... { RequestURL protocol }   private     function DoGetProtocol: string; { RequestURL protocol } ..... function TsgcWSConnectionServer.DoGetProtocol: string; var   i: Integer;   oSProtocols, oCProtocols: TsgcDelimitedStringList; begin   if FHandshake.Protocols <> '' then   begin     oSProtocols := TsgcDelimitedStringList.Create;     oCProtocols := TsgcDelimitedStringList.Create;     Try       oSProtocols.DelimitedText := Protocol;       oCProtocols.DelimitedText := FHandshake.Protocols;       for i := 0 to oCProtocols.Count - 1 do       begin         if oSProtocols.IndexOf(oCProtocols) > -1 then         begin           Result := oCProtocols;           break;         end;       end;       if Result = '' then         raise TsgcWSException.CreateFmt(S_PROTOCOL_UNSUPPORTED,           [oCProtocols.Text]);     Finally       sgcFree(oCProtocols);       sgcFree(oSProtocols);     End;   end; end; if somebody can help me i'll be grateful