How to solve 413 request entity too large - java

When I post a form with an image taken from my phone I reserve the error "413 request entity too large" I realize that an image included in the form taken by the phone camera is too large, and the server rejects the request... but how can I fix this issue, I'm using Java Spring framework, and MySQL database, all of this handled with Amazon aws services.

You have to modify your .platform as shown in the docs.
For example, you could have the following .platform/nginx/conf.d/myconfig.conf with content:
client_max_body_size 20M;

I struggled with this for so long until I came across this post:
https://medium.com/#robin.srimal/how-to-fix-a-413-request-entity-too-large-error-on-aws-elastic-beanstalk-ac2bb15f244d
Couple things to watch out for here, if your server is restarted or you deploy a new version etc, then your nginx server will also reset and you will need to perform these changes again. Also periodically, AWS seems to reset your EC2 instance address, not sure why, but you need to perform these changes again afterwards. There must be a way of making these changes permanent but I haven't figured that part out yet.

I find the solution thanks for helping...
1-I connect to my EC2 instance throw the "connect" button, a terminal appears.
2-I edit this file: etc/nginx/nginx.conf
3- Add this line:client_max_body_size 10M;
and it works fine.
thank you all ;

Related

The application on Angular does not receive a response from the server

There is an application on Angular, the backend is an application on Java-Spring.
Both of them are running on a server in a shared network, on a Windows OC machine in VirtualBox (Linux).
The essence of the problem is that when you try to open a web application in a browser, it runs completely on one computer out of five with Windows OC and on one of one on Linux OC.
The browser is everywhere Chrome, only in Linux Mozilla
The application itself is launched, but it does not receive data from the backend at startup.
At the same time I get an error
Failed to load resource:
http://10.151.78.6:5003/es-serv/api/v1/get-data/sh1 net::ERR_CONNECTION_RESET
Here is the controller method that receives requests, there is no call to it in the logs
#GetMapping("/get-data/" + RestApiConstants.VARIABLE_NAME)
public ResponseEntity<ListResponse<DataDto>> getData(
#PathVariable(RestApiConstants.PARAM_NAME_WORD) String name) {
log.info("getData -> start");
return converterDtoService.converterDataDto(name);
}
Moreover, if you just try to open the link in the browser bar
http://10.151.78.6:5003/es-serv/api/v1/get-data/sh1
Then I get the data every time, I have never noticed any failures.
Very similar to the problem with CORS, but then the browser gives a specific error to all requests. Yes, and cors is disabled in the Java application. And even then it is not clear why it still works on some browsers.
It doesn't look like a timeout problem either, because I get an error instantly, and when the server doesn't respond, some time passes and it's noticeable.
And another such moment, I added a forced data reading button to the application. And after 20-30 attempts to read the data, the answer may still come to those computers that did not receive them.
If it was a problem with the network, then it is unclear why on the same computer from the same browser, the GET request typed in the browser line gets answers all the time, without a single pass.
Tell me where to look to understand the reason?
The problem was solved by updating the browsers to the latest version. And before that, the browser version was not very old. I don't understand how this could affect the transmission of the GET request over the network?

Impossible to bypass a session timeout in my company

I am coming to you to see if someone get my issue.
Let me explain the context:
We have a back side coded in Kotlin/Vertx and a front Side in Angular 8.
We upload and download some files on the datalake storage from Azure Cloud.
How we do that? An explorer is implemented in the front side and when we want to download a file, a request is sent to the back side and once it is finished we send a response success/error from back side to the front side.
Everything works well in local environement on upload or Download.
One particularity, In download side we can download ONE or SEVERAL files And when it is 2 or more files we compress them on back side before returning the response to the front side and download the 7zip file.
And as I said above, everything works well in our local environment.
But I am working on a big company and there some security as 4 minutes session TimesOut.
So when we have to download a file with a big size on my company environment even if it takes more than 4 minutes, it works because it hapenning something during the download (some packet are downloading).
But when we have to compress Big files, the time that the backside is zipping files (more than 4 minutes) the session cut (some firewall or something )
I tried to add a keep alive in front side or back side it doesn't worked.
I also tried every http code I found on the web but it its happening nothing.
Do you know how I can keep this session open by some function in Vertx?
Because, every thing I tried from vertx documentation or stackoverflow failed.
Thanks a lot for reading me,
Regards

What and how should i use to send error logs from my java program onto a server (mail, git, etc...)

I have an alpha staged program with many bugs, and I would like to let people send their logs on a server (mail, git, etc...) so i can look them up and fix them. I have searched allot on this topic and I haven't found a way to do it without downloading a git full of logs, or needing an authentication for a mail or a dedicated server.
Is there a way to make my Java program send automatically its error log on a server when it crashes, without needing costly hardware or authentification? (i have a 0$ budget).
A free Loggly account sounds perfect for your needs.
You could use the javamail library to send emails to an account where you want to get the errorlogs. This wouldn't cost anything. And is very fast to implement/integrate in your project.
I would suggest to create a new gmail account which will send the emails to your account, where you want to recieve and debug it.

Atmosphere framework examples do not work. Any idea?

Perhaps I am going mad, but I've spent the whole day just trying to get the standard samples on the atomosphere (https://github.com/Atmosphere/atmosphere-samples/) to work. Specifically the 'chat'. The instructions are simple - I follow them:
mvn package
cd samples/chat
mvn jetty:run
I visit localhost:8080 and I see the default page - it tells me it connects to the websockets. I see on the Jetty logs it registers the connection. I enter the 'user name' as requested, and then I get a javascript error 'WebSocket not connected.' - after a couple of minutes it says "Connection lost, trying to reconnect. Trying to reconnect 5000" upon which it then connects and works without any issues. Its the same on Chrome, firefox and Safari. Its also the same on 2 different Macs (mavericks) and 1 Windows 7 PC. It consistently fails like this. I have no firewall, proxy , etc running.
I am going out of my mind, and I cannot proceed with my work/project. Its getting late here and I'm dreading another whole day at this getting no where. Any ideas or can some just test this to make sure I'm not going mad? I posted on the user group but just got 'its your environment'. I've tried 3 environments and it makes no difference.
thanks
Ok. I think this 'Fix' has broken the samples;
https://github.com/Atmosphere/atmosphere-javascript/issues/74
debugging the atmosphere.js I see that webSocketOpened = true; is never set, and hence why the client can't send any messages as it thinks the connection is not open even though it is.
If I used client 2.1.4-SNAPSHOT the samples work fine.

Unable to access files from MarkLogic Java API

In the process of showing demoing some new Java code that accesses a local MarkLogic server, I ran into the following error. It pops up any time I try to either load a file, or access its metadata:
Only XML and JSON error messages supported by MarkLogic server.
This is getting triggered in calls to TextDocumentManager.readMetadata() and TextDocumentManager.read(). The code works fine on my machine but NOT on my supervisor's (he's the one seeing the error), which makes me think I tweaked something in the database configuration during development but didn't write it down. Unfortunately, I can't think of what that would be. Does anybody have any suggestions?
The message indicates that the server responded with an error without a Content-Type header declaring error content as JSON or XML.
Thus far, we've seen that Java exception only when the server was not initialized as a REST server.
So, please check your connection parameters. If in doubt, use an HTTP client like curl to make the equivalent request of the REST server to verify that the request is accepted.
If the REST server seems to be operational, you can also turn on error logging on the REST server to help debug the Java client.
To answer the followup question (StackOverFlow timed out on the initial answer):
There's a UI for creating a REST server in InfoStudio database configuration.
Go to port 8000 at the /appservices/ path.
Select the Database from the drop down and click Configure
Add a REST API Instance near the bottom of the page
There's also a REST interface for the admin user (not the REST admin user) to create REST instances on port 8002. For information about those services, please see
http://docs.marklogic.com/REST/client/service-management

Categories

Resources