• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

websockets in CF11

New Here ,
Sep 03, 2015 Sep 03, 2015

Copy link to clipboard

Copied

Hello, I have been trying to get websockets working in our CF 11 update 6/IIS8 server to no success.  I would love to use SSL, but as part of my testing I have even tried non-ssl with no luck. The instructions I have followed are these, Using WebSocket with ColdFusion 11 | Adobe Developer Connection.

Using Chrome I see that I receive this for standard proxy configuration on a non-SSL connection, "Error during WebSocket handshake: Unexpected response code: 200." This does show as a ws connection.

If I configure the builtin server and use SSL the error is WebSocket connection to 'wss://name.of.server:8543/cfusion/cfusion' failed: Error in connection establishment: net::ERR_TIMED_OUT."  The name of server is correct just removed here since I've been testing at times without firewall to eliminate that problem. I don't get where the cfusion/cfusion is derived from however. I am not sure why it isn't using cfws there that the non-ssl ones do. Port 8543 is open (even when the firewall is on).

If I set secure = false and redo the builtin server without SSL, I get "failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT" and it is for ws.

I have seen a different page discuss changes needing made to server.xml. When I try them, I cannot get CF to restart.

IIS has websockets on, and I see the cfws directory in the IIS manager.

Thanks for any ideas as to what I might be missing.

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 09, 2015 Sep 09, 2015

Copy link to clipboard

Copied

Did you name any websocket channels in your Application.cfc?  Like this:

this.wschannels = [{name="stocks"},{name="chat"}];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 15, 2015 Sep 15, 2015

Copy link to clipboard

Copied

Thank you for the reply, the code we have has this in it:

<cfcomponent>

  <cfset this.name = "Cf11Examples">

  <cfset this.wschannels = [{name="chat"}]>

</cfcomponent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 15, 2015 Sep 15, 2015

Copy link to clipboard

Copied

That does your cfwebsocket call look like?  Are you then using JS after defining the endpoint in cfwebsocket?  If so can you also include that code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2015 Sep 17, 2015

Copy link to clipboard

Copied

Thanks for helping look. Our programmer said all this was plagerized, we are just wanting something working before we start customization. I have tried setting security to false and changing CF Admin to not use SSL just to see if the problem is with our cert, but that hasn't helped. I grabbed the programs, here is application.cfc:

<cfcomponent>

  <cfset this.name = "Cf11Examples">

  <cfset this.wschannels = [{name="chat"}]>

</cfcomponent>

And here is the index.cfm:

<cfwebsocket name="webSocketObj"

             onMessage="messageHandler"

             onError="errorHandler"

             onOpen="openHandler"

             onClose="closeHandler"

             subscribeTo="chat"

             secure="true" />

             <doctype html>

<head>

<title>WebSocket Example</title>

   <script type="text/javascript">

             messageHandler =  function(aEvent,aToken) {

                    if (aEvent.data) {

           var txt=document.getElementById("msgArea");

           txt.innerHTML += aEvent.data  +"<br />";

          }

        }

            openHandler = function() {

            alert("Connection is open");

        }

            closeHandler= function() {

            alert("Connection Closed");

       }

              errorHandler = function() {

            alert("Doh!");

            console.log(arguments);

       }

                 sendMessage = function() {

            var text = window.prompt("Enter some text","");

            if (text) {

                webSocketObj.publish("chat", text);

            }

        }

   </script>

</head>

<body>

    <div id="msgArea" />

    <input type="button" value="Send Message" onClick="sendMessage()">

</body>

</html>

Thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2015 Sep 18, 2015

Copy link to clipboard

Copied

LATEST

I got your code to work as expected. I copied your exact code to my ColdFusion 11 set-up, with two exceptions.

1) I changed the secure attribute to false.

2) I added form tags. In other words, I replaced the input tag with

<form>

<input type="button" value="Send Message" onClick="sendMessage()">

</form>

I left the websocket settings in the Coldfusion Administrator at their default values, as follows:

websocket_settings.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation