simon987 / Much-Assembly-Required

Assembly programming game
GNU General Public License v3.0
930 stars 87 forks source link

Uploading code of a size above 65536 bytes disconnects the client #229

Closed kevinramharak closed 4 years ago

kevinramharak commented 4 years ago

When the client tries to send a message above 65536 bytes on the socket server it will be disconnected with the following error: Resulting message size [73,728] is too large for configured max of [65,536].

This makes it impossible to upload code larger than ~3k lines.

This can be fixed with the following attribute:

/// Server/src/main/java/net/simon987/server/websocket/SocketServer.java
@WebSocket(maxTextMessageSize = SocketServer.MAX_TXT_MESSAGE_SIZE)
public class SocketServer {
    // default is 2 ** 16, so we multiply it by 4
    static final int MAX_TXT_MESSAGE_SIZE = 262144;
}

Tough it becomes questionable on how large a message can be.

kevinramharak commented 4 years ago

I would make a PR, but i haven't checked your refactored branch yet.

simon987 commented 4 years ago

Thanks, I'll try to find a reasonable maximum size and implement that change.

kevinramharak commented 4 years ago

Note that the limitation is a sane default. I'm not that well versed with websockets but maybe sending the code in multiple messages is a better way of handling this. Sending megabytes over the web socket is perfectly valid but sounds wastefull of resources.

simon987 commented 4 years ago

AFIK the WS messages are automatically split into chunks and re-constructed regardless of the maximum size limit, I personally don't foresee any resource utilization problem if we increase the limit

kevinramharak commented 4 years ago

Ah well if the protocol itself handles large messages in chunks then it probably isnt a problem.