Created
January 28, 2020 07:54
-
-
Save faxm0dem/48ef01ad4e0c2d71c74d30962c62861a to your computer and use it in GitHub Desktop.
riemann websocket client in Golang
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" | |
"log" | |
"golang.org/x/net/websocket" | |
) | |
func main() { | |
origin := "http://localhost/" | |
url := "ws://ccrtmon:443/index?subscribe=true&query=tagged%20%22syslog%22" | |
ws, err := websocket.Dial(url, "", origin) | |
if err != nil { | |
log.Fatal(err) | |
} | |
var msg = make([]byte, 4096) | |
var n int | |
for { | |
n, err = ws.Read(msg) | |
if err != nil { | |
log.Fatal(err) | |
} | |
// if err := json.Unmarshal(msg[:n] | |
//fmt.Printf("Received: %s.\n", msg[:n]) | |
fmt.Printf("%s\n", msg[:n]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment