B4J Question Websocket with fileupload 100k limit

Nizze

Active Member
Licensed User
Longtime User
Hi

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

Br Nizze
 

Nizze

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

The limit is set on that handler with this line:
B4X:
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 .

Br
 
Upvote 0

Nizze

Active Member
Licensed User
Longtime 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 ?

B4X:
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.Initialize
    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)
        Else
            ToastMessageShow("Fel vid uppladdning", False)
        End If
    End If
    j.Release
    
End Sub
 
Upvote 0

Nizze

Active Member
Licensed User
Longtime 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]}{0.0.0.0:81}
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
LEGACY
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:
Upvote 0

Nizze

Active Member
Licensed User
Longtime User
Hi

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">
<head>
<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>
</head>
<body>
<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">
</form>
<p id="result"></p>
<script>
$( document ).ready(function() {
b4j_connect("/websocket_with_fileupload/ws");

});

</script>
~l6820119569:
</body>

But noting in server logs ..

Br
Nizze
 
Upvote 0
Top