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 6197701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:52:06+00:00 2026-05-24T03:52:06+00:00

I am trying to get a simple WebSocket example to work on my machine

  • 0

I am trying to get a simple WebSocket example to work on my machine (localhost), I got JavaScript and C# running just fine and connecting, except that Chrome disconnects after handshake.

I have searched all morning and I think it has something to do with the same domain policy, as another “question” suggests, I have updated my browser to the latest version (12.xxx).

However I couldnt find a solution to my problem.

I am using on the C# side:

ConnectionOrigin = "http://localhost:8080";
ServerLocation = "ws://localhost:8181/test";

And I am running the JavaScript using a normal HTML file open straight from disk (file:/// on the url bar). I have also tried using XAMPP to host it locally but I always have the same problem.

Attached goes the log output of the C# program:

   New connection from 127.0.0.1:8181 requested. Handshaking ...
Reading handshake ...
GET /test HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: localhost:8181
Origin: null
Sec-WebSocket-Key1: R 506   I   2D }6 qFB  G0`@88J? 4
Sec-WebSocket-Key2: y  20   8403!24  L 5 8

Sending handshake ...
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://localhost:8080
WebSocket-Location: ws://localhost:8181/test


New connection from 127.0.0.1:8181 established.
http://localhost:8080
Data sent to the client ["Time at the server: 23-07-2011 12:57:27"]
Client disconnected.
Waiting for another connection attempt ...
  • 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-24T03:52:06+00:00Added an answer on May 24, 2026 at 3:52 am

    In case of this request:

    GET /test HTTP/1.1
    Upgrade: WebSocket
    Connection: Upgrade
    Host: localhost:8181
    Origin: null
    Sec-WebSocket-Key1: R 506   I   2D }6 qFB  G0`@88J? 4
    Sec-WebSocket-Key2: y  20   8403!24  L 5 8
    

    the response must be:

    HTTP/1.1 101 WebSocket Protocol Handshake
    Upgrade: WebSocket
    Connection: Upgrade
    Sec-WebSocket-Origin: null
    Sec-WebSocket-Location: ws://localhost:8181/test
    
    the response code here
    

    So:

    • It’s WebSocket and not Web Socket in the first line.
    • It’s Sec-WebSocket-... and not WebSocket-....
    • You did not include the response code which is the essential part of the handshake (of which the construction is described in the specs).
    • Also, you should use \r\n and not \n (in case you didn’t already).

    On a side note, you might want to consult chrome://net-internals/ (the Events tab and then look for the appropriate SOCKET_STREAM) to see what response Chrome actually received.

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

Sidebar

Related Questions

Just trying to get simple http server running and have no clue about ruby
I'm trying to get a simple Lift example running and I'm having a strange
I'm trying to get a simple multicasting example to work on Linux (I've tried
I'm trying to get this simple program to work on windows, but it crashes:
I am just trying to get my head around simple view switching for the
I'm trying to get a simple 1D fractal terrain generator to work for a
I'm trying to get a simple RestEasy project to work in Eclipse (with Jboss
Trying to get a simple string replace to work using a Groovy script. Tried
I've been trying to get a simple hello world web app running on Sinatra.
I've been trying to get this javascript animation to work for hours now, and

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.