Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with kcp golang server #21

Open
garlen-javier opened this issue May 1, 2021 · 6 comments
Open

Not working with kcp golang server #21

garlen-javier opened this issue May 1, 2021 · 6 comments

Comments

@garlen-javier
Copy link

I tried the example on this project but it seems the kcp for golang doesn’t work. Tried sending a message from this c# script but golang server won’t recognize it.

@limpo1989
Copy link
Owner

kcp-csharp currently not supported FEC & Packet level encryption. please disable your golang server FEC & Packet level encryption option

@garlen-javier
Copy link
Author

Tried it with the minimal example, I just use listen without the encryption example but no luck.

package main

import (
	"fmt"
	"io"
	"log"
	"net"
	"time"

	"github.com/xtaci/kcp-go/v5"
)

func main() {
	//	key := pbkdf2.Key([]byte("demo pass"), []byte("demo salt"), 1024, 32, sha1.New)
	//	block, _ := kcp.NewAESBlockCrypt(key)
	if listener, err := kcp.Listen("localhost:11000"); err == nil {
		// spin-up the client
		//go client()
		for {
			fmt.Println("awaiting connection")
			s, err := listener.Accept()

			if err != nil {
				log.Fatal(err)
			}
			go handleEcho(s)
		}
	} else {
		log.Fatal(err)
	}
}

// handleEcho send back everything it received
func handleEcho(conn net.Conn) {
	fmt.Println("new client")
	buf := make([]byte, 4096)
	for {
		n, err := conn.Read(buf)

		fmt.Println("read!!")
		if err != nil {
			log.Println(err)
			return
		}

		n, err = conn.Write(buf[:n])
		if err != nil {
			log.Println(err)
			return
		}
	}
}

@limpo1989
Copy link
Owner

Test OK
20210502003112

@garlen-javier
Copy link
Author

garlen-javier commented May 1, 2021

Weird I always get this error while yours working, any idea why this happened?

not_work

Edit: Already tried changing port but still same

@garlen-javier
Copy link
Author

Oh found the fix! I just remove the ip address in golang server and just leave the port number just like this ":11000" and it works, not sure what's the difference as I'm fairly new to backend stuff. Btw does this project ready for production use in unity3D?

@MouseChannel
Copy link

Oh found the fix! I just remove the ip address in golang server and just leave the port number just like this ":11000" and it works, not sure what's the difference as I'm fairly new to backend stuff. Btw does this project ready for production use in unity3D?

Im facing the same problem as yours.And I follow your fix to remove the ipAddress,it works.
Have you try encryption or serialize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants