[Solved] TcpClient broken?

I’m making a simple get request to an HTTP server which works fine in CURL but fails in Spark. I have a feeling it may be the buffer size in TcpClient but not sure how to build my own. The request looks like this (sensitive data changed):

GET /data.json?req=login&Token=&username=status&password=something HTTP/1.1
User-Agent: spark/1.0
Host: somewhere.com:8080
Accept: application/json

And the server usually says
HTTP/1.0 500 Array index is out of range.

What’s also strange is that it hangs a long time between User-Agent line and the rest (like the buffer is full and not moving)

I’ve sorta-kinda gotten around this. I put a node.js tcp service up to analyze what the Spark was sending. Although the content is the same, the framing is not. It sends the simple get in 9 separate TCP packets. My guess is the minecraft/mcmyadmin server I’m hitting has a bug somewhere with framing. It’s also pretty inefficient and slow to do it this way. So I’ve modified HttpClient to use a string buffer to assemble the request and send it all at once, and now it works fine.

4 Likes

Hey djMax,

I’m glad you got it working! I’m going to mark this as “solved” however if you have anything else to contribute feel free to post in this thread and I’ll unmark it.

[Edit] Looks like you are querying a minecraft server. I’m thinking about doing something similar for a project. We should collaborate :slight_smile: