Socket not work
kingsae1 opened this issue · 7 comments
Hey I want to use socket.io or socket(tcp). I tried to use the socket, but I couldn't. Can you tell me if there is anything I need to configure?
For reference, I'm using it well in nodejs, but it doesn't work when I use go
I don't really understand what you're trying to achieve. Can you explain it a little bit more ? With code example perhaps ?
Ok. I tried to open socket through message(message.go). Although opening port and checking get/post, couldn't use socket.
In case of inner webpage, checked clearing sendBuffer (socket.io). but after building, not clear that. I thought framework block the socket message ...
import socketio "github.com/googollee/go-socket.io"
server := socketio.NewServer(nil)
// Not work
server.OnConnect("/", func(s socketio.Conn) error {
fmt.Println("connected:", s.ID())
socket = s
return nil
})
// Not work
server.OnError("/", func(s socketio.Conn, e error) {
fmt.Println("meet error:", e)
})
// Not work
server.OnDisconnect("/", func(s socketio.Conn, reason string) {
fmt.Println("closed", reason)
})
go server.Serve()
defer server.Close()
// Working
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Socket Server")
})
// Not working
http.Handle("/socket.io/", server)
// Working
http.HandleFunc("/cap", func(w http.ResponseWriter, r *http.Request) {
// Done
fmt.Fprintf(w, "[Message] Cap")
})
I still don't understand what you're trying to achieve. What is the link with go-astilectron
?
Oh sorry. The comment location is wrong. I used it from the link: https://github.com/asticode/go-astilectron-bundler. Even so, the core uses inner go-atilectron, please review whether it is related or not.
Let me explain in detail again. While looking for a web packaging framework using Go, I found go-astilectron-bundler. Using this, a process is created using a socket between Go-Web-Server. I was migrating Nodejs Sockets to Go because I wanted to package the parts that used sockets using existing Nodejs all at once using Go. However, when bundling using go-astilectron, it did not work, so I inquired.
I think you misunderstood the goal of this project : go-astilectron
allows you to use and command Electron
from go
. It's not a web packaging framework, it's an electron
packaging framework.
To function properly, go-astilectron
uses an internal socket to communicate with Electron
but it's meant to stay private and should not be accessed.
What is loaded in Electron
is entirely up to you, and this is where you can load a custom server. But go-astilectron
won't help you creating that server.
Does that make sense?
Thank you for your comment. Let's proceed with what you said :)