FAQ
client and server's codes keep same with
https://github.com/astaxie/build-web-application-with-golang/blob/master/ebook/08.2.md ,I
open the client with Chrome, server with CMD, and the console said:

onload
index.html:10 WebSocket connection to 'ws://localhost:1234/' failed: Error
  during WebSocket handshake: Unexpected response code: 403
index.html:12 connection closed (1006)
index.html:19 WebSocket is already in CLOSING or CLOSED state.
No message at server-end.

<F12>-Network-Header:


    1. Request URL:
    ws://localhost:1234/
    2. Request Headers CAUTION: Provisional headers are shown.
       1. Cache-Control:
       no-cache
       2. Connection:
       Upgrade
       3. Host:
       localhost:1234
       4. Origin:
       null
       5. Pragma:
       no-cache
       6. Sec-WebSocket-Extensions:
       permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
       7. Sec-WebSocket-Key:
       jE5tbcaUK+vcLJ9rjdr1Fw==
       8. Sec-WebSocket-Version:
       13
       9. Upgrade:
       websocket
       10. User-Agent:
       Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko)
       Chrome/35.0.1916.153 Safari/537.36
       11.


chrome://net-internals/#events:
7969: SOCKET
ws://localhost:1234/
Start Time: 2014-07-17 13:58:20.672

t=2491386 [st= 0] +SOCKET_ALIVE [dt=12]
   --> source_dependency = 7965 (SOCKET_STREAM)
t=2491386 [st= 0] +TCP_CONNECT [dt=1]
  --> address_list = ["[::1]:1234","127.0.0.1:1234"]
t=2491386 [st= 0] TCP_CONNECT_ATTEMPT [dt=1]
  --> address = "[::1]:1234"
t=2491387 [st= 1] -TCP_CONNECT
  --> source_address = "[::1]:51589"
t=2491389 [st= 3] SOCKET_BYTES_SENT
  --> byte_count = 420
t=2491398 [st=12] SOCKET_BYTES_RECEIVED
  --> byte_count = 26
t=2491398 [st=12] -SOCKET_ALIVE

I don't know how to dea with it. It just couldn't run the same result with
the github's. Thx for your help!

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dave Cheney at Jul 20, 2014 at 3:58 am
    Change the server code to print out the error value, rather than just
    printing the fact there was an error. That should get you a little further.
    On Thursday, 17 July 2014 21:33:56 UTC+10, 王利 wrote:

    client and server's codes keep same with
    https://github.com/astaxie/build-web-application-with-golang/blob/master/ebook/08.2.md ,I
    open the client with Chrome, server with CMD, and the console said:

    onload
    index.html:10 WebSocket connection to 'ws://localhost:1234/' failed: Error
    during WebSocket handshake: Unexpected response code: 403
    index.html:12 connection closed (1006)
    index.html:19 WebSocket is already in CLOSING or CLOSED state.
    No message at server-end.

    <F12>-Network-Header:


    1. Request URL:
    ws://localhost:1234/
    2. Request Headers CAUTION: Provisional headers are shown.
    1. Cache-Control:
    no-cache
    2. Connection:
    Upgrade
    3. Host:
    localhost:1234
    4. Origin:
    null
    5. Pragma:
    no-cache
    6. Sec-WebSocket-Extensions:
    permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
    7. Sec-WebSocket-Key:
    jE5tbcaUK+vcLJ9rjdr1Fw==
    8. Sec-WebSocket-Version:
    13
    9. Upgrade:
    websocket
    10. User-Agent:
    Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko)
    Chrome/35.0.1916.153 Safari/537.36
    11.


    chrome://net-internals/#events:
    7969: SOCKET
    ws://localhost:1234/
    Start Time: 2014-07-17 13:58:20.672

    t=2491386 [st= 0] +SOCKET_ALIVE [dt=12]
    --> source_dependency = 7965 (SOCKET_STREAM)
    t=2491386 [st= 0] +TCP_CONNECT [dt=1]
    --> address_list = ["[::1]:1234","127.0.0.1:1234"]
    t=2491386 [st= 0] TCP_CONNECT_ATTEMPT [dt=1]
    --> address = "[::1]:1234"
    t=2491387 [st= 1] -TCP_CONNECT
    --> source_address = "[::1]:51589"
    t=2491389 [st= 3] SOCKET_BYTES_SENT
    --> byte_count = 420
    t=2491398 [st=12] SOCKET_BYTES_RECEIVED
    --> byte_count = 26
    t=2491398 [st=12] -SOCKET_ALIVE

    I don't know how to dea with it. It just couldn't run the same result with
    the github's. Thx for your help!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jeffrey Smith at Jul 20, 2014 at 11:06 am
    The Origin header is not set which will probably throw a 403.

    You will have to set this where ever you are serving up the html page from.


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 17, '14 at 11:34a
activeJul 20, '14 at 11:06a
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase