B4J Question Websocket with fileupload 100k limit


Active Member
Licensed User

Where can i change Erels Serverexample to accept more then 100 k ?
In websocket with fileupload.

Br Nizze


Active Member
Licensed User
The file is actually loaded to a regular handler named FileHelper.

The limit is set on that handler with this line:
Dim data As Map = req.GetMultipartData(Main.TempDir, 100000)
Thanks !
It worked perfect

Is there anything more i have to change to use it from WAN ?
I have made a port redierect on port 51042 .



Active Member
Licensed User
Hi ..

I missed that i use R12 server with built in firewall ....
So after a small change there it worked

So now the webpage work with upload

Imtrying to upload a movie from android with this code that worked with PHP

But it do not work here , is there a workaround ?

Sub Doning1(filname As String)
    PostPath = "http://www.XXXXX.com/websocket_with_fileupload/index.html"
    Dim j As HttpJob
    j.Initialize("", Me)
    Dim mp As MultipartFileData
    mp.Dir = rp.GetSafeDirDefaultExternal("")
    mp.FileName = filname
    mp.KeyName = "file"
    mp.ContentType = "video/mp4"
    j.PostMultipart(PostPath, Null, Array(mp))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log("- - - - - - - - - - - - - ")
        If filname = j.GetString Then
            ToastMessageShow("Film upladdad.", False)
            ToastMessageShow("Fel vid uppladdning", False)
        End If
    End If
End Sub


Active Member
Licensed User
What happens when it doesn't work?

Server and client logs.
Mornings !
Can't see much in those logs . ...
From a pc and Chrome itworks to upload a file , with the same URL . ( http://www.XXXXX.com/websocket_with_fileupload/index.html )

Serverside shows nothing ( B4J ) .
Waiting for debugger to connect...
Program started.
08:06:05 -- C:\Projekt\B4J\SERVER~2\Objects\temp
2019-09-18 08:06:05.250:INFO::main: Logging initialized @830ms to org.eclipse.jetty.util.log.StdErrLog
2019-09-18 08:06:05.408:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_191-b12
2019-09-18 08:06:05.460:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2019-09-18 08:06:05.460:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2019-09-18 08:06:05.462:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2019-09-18 08:06:05.487:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@c273d3{/,file:///C:/Projekt/B4J/ServerExampleNoMySQL/Objects/www/,AVAILABLE}
2019-09-18 08:06:05.491:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Projekt\B4J\ServerExampleNoMySQL\Objects\logs\b4j-2019_09_18.request.log
2019-09-18 08:06:05.551:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@1970963{HTTP/1.1,[http/1.1]}{}
2019-09-18 08:06:05.551:INFO:eek:ejs.Server:main: Started @1133ms
Emulated network latency: 200ms
08:06:05 -- Server started
And in client Side ( B4A )

08:10:18 -- Main Load cam page
Start success: true
(Rect)(0, 0, 3264, 2448)
Start success: true
(Rect)(0, 0, 3264, 2448)
Videofile : 1.mp4
*** Service (httputils2service) Create ***
*** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
java.net.SocketTimeoutException: timeout

This is the log ( From server ) when uploading from PC

08:06:05 -- Server started
08:57:51 -- [ws=anywheresoftware.b4j.object.WebSocket@b6cbcc, form1=anywheresoftware.b4j.object.WebSocket$JQueryElement@a7e666, result=anywheresoftware.b4j.object.WebSocket$JQueryElement@bbe345
, dateutils=null, main=null, bra_saker=null
, webutils=null, pushshared=null, chatshared=null
, dbutils=null]
08:57:54 -- 1.mp4
08:57:54 -- C:\Projekt\B4J\ServerExampleNoMySQL\Objects\temp\MultiPart7661210167037367669
Last edited:


Active Member
Licensed User

If i take a photo i get this in Android log

Start success: true
(Rect)(0, 0, 3264, 2448)
Picture taken: (Bitmap): 1920 x 1080, scale = 1,00
Photo dir /storage/emulated/0/Android/data/nn.test/files
Doning 2.jpg
- - - - - - - - - - - - -
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Upload tool </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="index.css" />
<script src="/b4j_ws.js"></script>
<script src="jquery.form.min.js"></script>
<h1>Upload tool </h1>
<form id="form1" action="filehelper" method="post" enctype="multipart/form-data">
<label for="file">Välj fil (max storlek 1Gb):</label>
<input type="file" name="file1">
<input type="submit" name="submit" value="Submit">
<p id="result"></p>
$( document ).ready(function() {


But noting in server logs ..