Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:55+00:00 2026-05-23T00:56:55+00:00

I am using javascript to connect websocket: <script> var socket; var host = ws://localhost:8000/socket/server/startDaemon.php;

  • 0

I am using javascript to connect websocket:

<script>
    var socket;  
    var host = "ws://localhost:8000/socket/server/startDaemon.php";  
    var socket = new WebSocket(host);  
</script>

I got the error:

Can’t establish a connection to the server at

var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);

How can I solve this issue?

NOTE : I enabled websocket in mozilla to support web socket application.
and when i run in chrome i got error:

   can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:56:56+00:00Added an answer on May 23, 2026 at 12:56 am

    I solved my error by following code through this link

    http://www.flynsarmy.com/2010/05/php-web-socket-chat-application/
    and created socketWebSocketTrigger.class.php file for response message where code as

    class socketWebSocketTrigger
    {   
    
            function responseMessage($param)
            {
                $a = 'Unknown parameter';
    
                if($param == 'age'){
                    $a = "Oh dear, I'm 152";
                }
    
                if($param == 'hello'){
                    $a = 'hello, how are you?';
                }
    
                if($param == 'name'){
                    $a = 'my name is Mr. websocket';
                }
    
                if($param == 'today'){
                    $a = date('Y-m-d');
                }
    
                if($param == 'hi'){
                    $a = 'hi there';
                }
    
                return $a;
    
            }
    
    }
    

    and added code in send function of ‘WebSocketServer.php’ for calling ‘responseMessage’ function which response request message

     public function send($client, $msg){
            $this->say("> ".$msg);
            $messageRequest = json_decode($msg,true);
    
                // $action=$messageRequest[0];
                $action = 'responseMessage';
                $param  = $messageRequest[1]['data'];
            if( method_exists('socketWebSocketTrigger',$action) ){
                                    $response = socketWebSocketTrigger::$action($param);
                                }
                $msg = json_encode(
                    array(                      
                    'message',
                        array('data' => $response)
                    )
                );
    
                $msg = $this->wrap($msg);
    
            socket_write($client, $msg, strlen($msg));
        }
    

    it’s working great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a WebSocket server (C#) and a client (JavaScript / HTML5). This
I am using FB.init to connect using FB connect javascript APIs. I have tested
I use the javascript to get some data from facebook using javascript sdk: window.fbAsyncInit
I'm looking at options to connect directly--without a web server or middleware--to a PostgreSQL
I have a game server written in python and twisted, and an old game
Is there a way to get a variable name as a string in Javascript?
I am creating a server to monitor the online presence of clients on a
I'm using pyfacebook on my app but I'm having problems displaying xfbml For example
I am trying to get a streampublish box with facebook's new graph api example.
I'm looking for a secure way to store FTP passwords in a database that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.