简体   繁体   English

无法连接到MtGox Websocket

[英]Can't connect to MtGox Websocket

I've tried every possibily combination for the URI, below is my code. 我已经尝试过URI的所有可能组合,以下是我的代码。 When using the webpage http://www.websocket.org/echo.html and for "Location: " entering ws://websocket.mtgox.com/mtgox, the webpage shows a nice feed for the stream. 当使用网页http://www.websocket.org/echo.html并在“位置:”中输入ws://websocket.mtgox.com/mtgox时,该网页将显示一个不错的流源。 But when I copy and paste their example below, and use the same URI for the stream, I get "Error: Undefined" and the "DISCONNECTING". 但是,当我在下面复制并粘贴其示例,并对流使用相同的URI时,出现“错误:未定义”和“断开连接”。 I've tried converting this to VB, as per the example below, with no luck. 我尝试按照下面的示例将其转换为VB,但是没有运气。 Any ideas as to what I am doing wrong? 关于我在做什么错的任何想法吗?

Imports WebSocket4Net 导入WebSocket4Net

Module Module1 模块Module1

Sub Main()

    Dim websocket As New WebSocket4Net.WebSocket("ws://websocket.mtgox.com:80/mtgox")
    Dim stream As String

    Console.WriteLine(websocket.State)
    Console.ReadKey()




    AddHandler websocket.Opened, Sub(s, e) socketOpened()
    AddHandler websocket.Error, Sub(s, e) socketError()
    AddHandler websocket.Closed, Sub(s, e) socketClosed()
    AddHandler websocket.MessageReceived, Sub(s, e) socketMessage()
    AddHandler websocket.DataReceived, Sub(s, e) socketDataReceived()

    websocket.Open()

    Console.ReadKey()

End Sub

Sub socketOpened()
    MsgBox("Opened")
End Sub

Sub socketClosed()
    MsgBox("Closed")
End Sub

Sub socketError()
    MsgBox("Error")
End Sub

Sub socketMessage()
    'MsgBox(e)
End Sub

Sub socketDataReceived()
    MsgBox("Data received")
End Sub

End Module 终端模块

I am not familiar with WebSocket4Net, but this may be related to a similar issue that someone had with another library ( MtGox API and websocketpp ) where the lack of an Origin header caused MtGox to cancel the connection with a 403 error. 我对WebSocket4Net不熟悉,但这可能与另一个库( MtGox API和websocketpp )中有人遇到的类似问题有关,其中缺少Origin标头导致MtGox取消了403错误的连接。

It worked from browsers because they all send the Origin header. 它在浏览器中有效,因为它们都发送Origin头。 If your WebSocket implementation has a method of adding an Origin header to the outgoing handshake that might be worth a shot. 如果您的WebSocket实现具有将Origin标头添加到外出握手中的方法,那么可能值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM