Created
August 25, 2023 15:09
-
-
Save benhenryhunter/19c3cf691642214f34ea9a4f08974c88 to your computer and use it in GitHub Desktop.
websocket with blxr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/gorilla/websocket" | |
) | |
func main() { | |
header := http.Header{} | |
header.Set("Authorization", "<YOUR-AUTHORIZATION-HEADER>") | |
wsURL := fmt.Sprintf("ws://bloxroute.max-profit.blxrbdn.com/blxr/ws") | |
conn, _, err := websocket.DefaultDialer.Dial(wsURL, header) | |
if err != nil { | |
fmt.Println("Could not connect to relay websocket", "url", wsURL, "err", err) | |
// return conn, err | |
} else { | |
fmt.Println("connected") | |
} | |
if err := conn.WriteJSON(map[string]interface{}{"yo": "yo"}); err != nil { | |
fmt.Println("error writing json", err) | |
} else { | |
_, b, err := conn.ReadMessage() | |
if err != nil { | |
fmt.Println("error reading message", err) | |
} else { | |
fmt.Println(string(b)) | |
} | |
} | |
// return conn, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment