STOMP CONNECTION using WebsocketApr 22, 2014 07:38 AM
<P>Hi,</P><P>I need to establish the STOMP connection using Web Socket, I checked the documentation <A target="_blank" href="https://developer.att.com/static-assets/documents/apis/in-app-messaging.pdf" rel="nofollow noopener noreferrer">https://developer.att.com/static-assets/documents/apis/in-app-messaging.pdf</A></P><P>and when I try to connect with the ATT server the event OnOpen not fires. Here an example:</P><P> </P><P>class Program<BR />{<BR />static void Main(string[] args)<BR />{<BR />var client = new XSocketClient("wss://encprodsockjs.att.net/stomp/websocket", "*");</P><P>client.OnOpen += (sender, eventArgs) => Console.WriteLine("OPEN");<BR />client.Bind("foo", message => Console.WriteLine(message.data));<BR />client.Open();</P><P>//Send a message for every key press... Until Escape<BR />ConsoleKeyInfo cki;<BR />Console.WriteLine("Press the Escape (Esc) key to quit and any other key to send a message: \n");<BR />do<BR />{<BR />cki = Console.ReadKey();<BR />if (cki.Key != ConsoleKey.Escape) {<BR />//Send a message<BR />client.Send("Hello this is the c# client!!", "foo");<BR />}<BR />} while (cki.Key != ConsoleKey.Escape);<BR />}<BR />}</P><P>But If I replace the ATT server by my local server "<SPAN>ws://127.0.0.1:4502/Generic" the event fires.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>An the other hand, also I try to setup connection using the login and passcode in order to use the Send method but the event not fire:</SPAN></P><P><SPAN> </SPAN></P><P>string username = "*************************";<BR />string password = "*************************";</P><P>StringBuilder RequestConnection = new StringBuilder();<BR />RequestConnection.Append("CONNECT");<BR />RequestConnection.Append("\r\n");<BR />RequestConnection.Append("accept-version: 1.1");<BR />RequestConnection.Append("\r\n");<BR />RequestConnection.Append("login : " + username);<BR />RequestConnection.Append("\r\n");<BR />RequestConnection.Append("passcode :" + password);<BR />RequestConnection.Append("\r\n");<BR />RequestConnection.Append("\0");<BR />strRequestConnection = Convert.ToString(RequestConnection);</P><P>//oXSocketClient.OnOpen += oXSocketClientOpen;<BR />oXSocketClient.Open();<BR />oXSocketClient.Send(strRequestConnection);</P><P> </P><P>Any ideas ?</P><P> </P><P>Regards</P><P> </P>
'Re: STOMP CONNECTION using Websocket'Apr 22, 2014 09:08 AM
Hi,
In reviewing your code, the question of what you are attempting to accomplish comes to mnd. The SDK would be your best bet, depending on what you want to do.
Beyond this, I suggest starting with a known good cURL script which works as you need.
Then create your code duplicating the same header and body details. Once that works, you can further expand for your use.
'Re: STOMP CONNECTION using Websocket'Apr 22, 2014 02:20 PM
Hi, Thanks for your response. I've tried to do a simple html page in order to establish the connection and in the google console appers this message : "WebSocket connection to 'wss://encprodsockjs.att.net/stomp/websocket' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received" and I don't know why....
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="Scripts/XSockets.latest.js"></script> <script src="Scripts/jquery-2.1.0.js"></script> <script> var conn; conn = new XSockets.WebSocket('wss://encprodsockjs.att.net:443/stomp/websocket', 'myprotocol'); conn.on(XSockets.Events.open, function (clientInfo) { console.log('Open', clientInfo); });
'Re: STOMP CONNECTION using Websocket'Apr 29, 2014 03:21 PM
Thank you for help, finally I used the WebSocket4Net library in order to establish the stomp connection using websocket and works!. This is the link: http://websocket4net.codeplex.com/
Thanks You!
Please confirm that you want to flag this content as inappropriate.
???forums.modal.inappropriate.message???
Please confirm that you want to delete this content.