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

server cannot reply with a message of size 65536 bytes to client. #18

Open
glycerine opened this issue Dec 4, 2024 · 2 comments
Open
Assignees

Comments

@glycerine
Copy link

glycerine commented Dec 4, 2024

See my fork here

https://github.com/glycerine/go-wolfssl

specifically at commit cd11bed (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
@dgarske dgarske assigned gasbytes and lealem47 and unassigned gasbytes Dec 4, 2024
@lealem47
Copy link
Contributor

lealem47 commented Dec 5, 2024

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.

@gasbytes gasbytes assigned gasbytes and lealem47 and unassigned lealem47 and gasbytes Dec 11, 2024
@lealem47
Copy link
Contributor

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.

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