server cannot reply with a message of size 65536 bytes to client.
See my fork here
https://github.com/glycerine/go-wolfssl
specifically at commit cd11bedcb95f0d8d76825555d1136ea86cffaf6b (currently tip of master branch as of this writing).
Sometimes the server's reply of 65536 bytes fails on the first write. Other times it fails on the 2nd write.
To reproduce:
Run server:
jaten@rog ~/go/src/github.com/wolfssl/go-wolfssl/examples/server (master) $ rm httplike; go build httplike.go; ./httplike
Listening on localhost:11111
Client Succesfully Connected!
Client says : Can you hear me?^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
Client Succesfully Connected!
Client says : Can you hear me?^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
WolfSSL_write failed
jaten@rog ~/go/src/github.com/wolfssl/go-wolfssl/examples/server (master) $
In another terminal, run the client:
jaten@rog ~/go/src/github.com/wolfssl/go-wolfssl/examples/client (master) $ rm client; g\
o build client.go; ./client
# github.com/wolfssl/go-wolfssl
cgo-gcc-prolog: In function ‘_cgo_acb84add02d8_Cfunc_wolfSSL_Debugging_OFF’:
cgo-gcc-prolog:334:49: warning: unused variable ‘_cgo_a’ [-Wunused-variable]
Succesfully Connected!
Server reply was 5000000 bytes long
jaten@rog ~/go/src/github.com/wolfssl/go-wolfssl/examples/client (master) $ ./client
Succesfully Connected!
Server reply was 5000000 bytes long
jaten@rog ~/go/src/github.com/wolfssl/go-wolfssl/examples/client (master) $ ./client
Succesfully Connected!
Server reply was 5000000 bytes long
Hi again @glycerine,
Thank you for this detailed report. I've reproduced the issue and am looking into it. I'll let you know as soon as I have an update.
Thanks.
Hi @glycerine,
After taking a look this, it looks like modifying client.go to read on a loop is all that's needed to get things working. Calling it once is all that was required for a simple TLS example, but for a connection where we're expecting a larger amount of data, the read should be called until no more bytes are able to be read, as shown below:
for {
buf := make([]byte, 5e6)
ret = wolfSSL.WolfSSL_read(ssl, buf, uintptr(len(buf)))
if ret == -1 {
fmt.Println(" wolfSSL_read failed ")
} else {
fmt.Printf("Server reply was %v bytes long and ret was %d\n", len(buf), ret)
}
if ret <= 0 {
break
}
}
Thanks.
Hi @glycerine,
I'm closing this as we haven't heard back.
Thanks