0 Replies Latest reply on Feb 27, 2016 3:46 AM by zebrone92

    How to connect Photon by Particle to a Wildfly websocket application?

    zebrone92

      I'm trying to connect a Photon by Particle with a JavaEE webserver Wildfly with websocket. Here is the code running on Photon:

        #include "Spark-Websockets/Spark-Websockets.h"   WebSocketClient client;   void onMessage(WebSocketClient client, char* message) { Serial.print("Received: "); Serial.println(message); }   /* This function is called once at start up ----------------------------------*/ void setup() { Serial.begin(9600); //while(!Serial.available()); // Wait here until the user presses ENTER in the Serial Terminal  client.onMessage(onMessage); Serial.println(WiFi.localIP()); client.connect("192.168.10.150",8080,NULL,"/ExampleWebSocket/example"); }  void loop() { client.monitor(); delay(3000); client.send("Hello World"); }

      And here is the software running on JavaEE wildfly sever, which is in the same LAN:

         @ServerEndpoint("/example") public class WSEndpoint { Logger log = Logger.getLogger(this.getClass());  @OnMessage public void receiveMessage(String message, Session session) { log.info(message); } }  @OnOpen public void open(Session session) { log.info("Open session:" + session.getId()); }  @OnClose public void close(Session session, CloseReason c) { log.info("Closing:" + session.getId()); } }

      Here is the error I'm getting from the console of Photon:

      Handshake sent Reading handshake! handshake rcvd line: HTTP/1.1 200 OK handshake rcvd line: Connection: keep-alive handshake rcvd line: Last-Modified: Mon, 22 Feb 2016 07:43:20 GMT handshake rcvd line: X-Powered-By: Undertow/1 handshake rcvd line: Server: WildFly/9handshake rcvd line: Content-Length: 2425 handshake rcvd line: Content-Type: text/htmlhandshake rcvd line: Date: Fri, 26 Feb 2016 17:13:05 GMT handshake rcvd line: Handshake Failed! Terminating Connection Failed!

      What's the problem ? How Can I solve it?