Notifications
Q&A

Will my implementation of a Spring Boot app work after being deployed on the Internet?

+2
−0

Say I want to implement a very basic group chat application. I use the H2 database, a user class, a controller, and a text file in the Resources folder that stores the chat texts. All texts would be appended to the text file and a JS function would refresh the page periodically with the file data. Now of course this will directly work only within my network. But if I upload this project to Heroku or something similar, would it still work as intended?

Almost all examples online use WebSocket. I'm unable to understand why because everyone connecting to the my app online will be served by the same controller and append data to the same text file. Or am I completely wrong?

Why should this post be closed?

1 comment

"Now of course this will directly work only within my network." - this is not clear. Why exactly? I expect the text file to be hosted on a server rather than on the client. You should start by making a little drawing containing the components of your applications, write what they are doing and how they interact to have a clearer picture of what does what in the application. ‭Alexei‭ 19 days ago

1 answer

+2
−0

Now of course this will directly work only within my network. But if I upload this project to Heroku or something similar, would it still work as intended?

I'll assume that you actually have the project working on your network. The only advice I can really give you here is, "Try it and see if it works." And if it doesn't work, debug.

Almost all examples online use WebSocket. I'm unable to understand why because everyone connecting to the my app online will be served by the same controller and append data to the same text file. Or am I completely wrong?

The reason most examples use WebSocket is because WebSockets are bi-directional. i.e, the server can push data to the client without being asked for it. Obviously, this is ideal for real-time chat applications, where you want the server to send you chat updates as fast as possible.

In your case though, you are using the "repeatedly polling the server for data" method. While theoretically, this would work, it would only update the chat log as fast as the client requests data. Further, depending on how frequently you poll the server, this can be resource intensive on the server because the data is being repeatedly requested even when there are no changes. However, it does have the advantage of not having to maintain an active connection, so if you don't need real-time updates then this is a perfectly viable method.

0 comments

Sign up to answer this question »