Hi all!
I already asked this on
reddit, but I figured might as well ask it here.
Im trying to implement a custom TCP client. This protocol allows request from both the client and the server
Scenario 1:
Client -------REQUEST------> Server
Client <-----RESPONSE------- Server
Scenario 2:
Client <------REQUEST-------- Server
Client -------RESPONSE------> Server
Here's simplified form of the client. This approach uses a goroutine to read the
net.Conn, parse the string to determine the type,
and send the string to the appropriate channel for that type. Typical usage of this client is as follows
c := client.New("localhost:8888")
c.Connect()
c.Send("message")
On small workloads, it works fine, however calling Send around 100 times a second times out.
I can confirm using wireshark that the server indeed sent a response, however it seems like the readLoop wasn't able read it and send it to the channel.
I would like to ask if this approach is reasonable. Id like to ask anyone out there have implemented a client golang library thats able to both send and receive requests from the server. Basically a bidirectional tcp client. I know nats is similar to this, however their protocol parsing is too complex for me. Any new approach/advise will be nice. Thanks!