Use four Thread to upload files at same time, the server does not accept the upload request

java

(Leonard) #1

Use four Thread to upload files at same time, the server does not accept the upload request. But use three thread to upload the file at same time use Jmeter, can receive the request and success.
Who has encountered this problem?


(Will Sargent) #2

You need to describe how you have threads configured, and in what context. Generally you would use a custom execution context and a Future or CompleteableStage in Play.

Please see https://www.playframework.com/documentation/2.6.x/ThreadPools#using-other-thread-pools and CustomExecutionContext and provide a sample project on Github and maybe it’ll be clearer what the issue is here.


(Leonard) #3

Thank you for your reply, and I resolved my problem use another upload method, and use the correnct ws chain structure.
before like this:

Source<ByteString, ?> file = FileIO.fromFile(new File("hello.txt"));
FilePart<Source<ByteString, ?>> fp = new FilePart<>("hello", "hello.txt", "text/plain", file);
DataPart dp = new DataPart("key", "value");

ws.url(url).post(Source.from(Arrays.asList(fp, dp)));

Updated like this:

ws.url(url).setBody(largeImage).execute("PUT");