簡體   English   中英

無法連接到MtGox Websocket

[英]Can't connect to MtGox Websocket

我已經嘗試過URI的所有可能組合,以下是我的代碼。 當使用網頁http://www.websocket.org/echo.html並在“位置:”中輸入ws://websocket.mtgox.com/mtgox時,該網頁將顯示一個不錯的流源。 但是,當我在下面復制並粘貼其示例,並對流使用相同的URI時,出現“錯誤:未定義”和“斷開連接”。 我嘗試按照下面的示例將其轉換為VB,但是沒有運氣。 關於我在做什么錯的任何想法嗎?

導入WebSocket4Net

模塊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

終端模塊

我對WebSocket4Net不熟悉,但這可能與另一個庫( MtGox API和websocketpp )中有人遇到的類似問題有關,其中缺少Origin標頭導致MtGox取消了403錯誤的連接。

它在瀏覽器中有效,因為它們都發送Origin頭。 如果您的WebSocket實現具有將Origin標頭添加到外出握手中的方法,那么可能值得一試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM