B4J Question JobDone (FileNotFoundException) , forgive the insistence on my problem

ivanomonti

Expert
Licensed User
Longtime User
I eliminated all the java.sun errors... that I identified in the comboboxes that crashed for no reason (what happened to me) the special fonts were not the problem (at first I thought of them)

now I have set the default folder of HttpUtils2Service with this code proposed by erel in other posts and it works perfectly


B4X:
HttpUtils2Service.Service_Create
HttpUtils2Service.TempFolder = pathDesktop & "/SETTING/"

But I still encounter the jobdone problem, I state that the time that requests the data service (cannot be less) is every 600 tik (0.6 sec) this is the set speed but I should bring it to 500 tik, the temporary files they are written regularly but not all and many remain in the folder and are not deleted by HttpUtils2Service itself.

How can I proceed, also because I lose those files just as I lose the data I need?


B4X:
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\6759 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\7147 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\7675 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\8029 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\8328 (Impossibile 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by anywheresoftware.b4j.object.JavaObject (file:/C:/Program%20Files/Anywhere%20Software/B4J/Libraries/JavaObject.jar) to method sun.awt.windows.WToolkit.beep()
WARNING: Please consider reporting this to the maintainers of anywheresoftware.b4j.object.JavaObject
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
refesh di maye dettato dal grafico piatto
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\8839 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\9050 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\9279 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\9438 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\9491 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\9985 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\10443 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\11078 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\11730 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\11765 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\11906 (Impossibile trovare il file specificato)
ERROR: JobDone (FileNotFoundException) java.io.FileNotFoundException: C:\Users\MontiIvanoAngelo\Desktop\Trading Forex Maye by Ivano and Lorenzo\SETTING\12029 (Impossibile trovare il file specificato)
*** mainpage: B4XPage_Disappear [mainpage]

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg
 

LucaMs

Expert
Licensed User
Longtime User
Just guessing...

"File not found" but also a warning that mentions "illegal access". Maybe you repeatedly, quickly query an online service, requesting files that you download to a temporary folder on the desktop, but they are not sent to you due to illegal access and therefore your project then cannot find them (file not found)?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Maybe you repeatedly, quickly query an online service
@Diceman and I ran into similar "errors" in the past and attributed them to high frequency requests. See https://www.b4x.com/android/forum/t...session-id-in-jrdc2-client.108642/post-686346
This was my unproven guess as to what may be happening:
My guess was that so many http jobs were running that one was assigned the same random file name as another. So once one job was finished, it deleted the file, bombing out the other http job. I was going to make a question post out of this one, but never got to it. It only happened when I had lots of http jobs running (therefore my guess).
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
One thing going against this guess is that file locking should prevent this from happening?
every 500 milliseconds a stock market value changes, these values are used to compare the currency with the previous values and then take an action, losing them the action fails
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
We cannot guess what you are doing. Post the relevant code.

and a simple timer that makes requests to the server and nothing more, every 500 milliseconds a stock value changes, these values are used to compare the currency with the previous values and then take an action, losing them the action fails


B4X:
Dim api As String
api = link
If cambio="" Then api = link
htpjob.Download(api)


B4X:
    Try
        If job.Success And job.JobName="price" Then
            Dim res As String
            Dim gap As Double
            res = job.GetString
            Dim parser As JSONParser
            parser.Initialize(res)
            Dim record As Map
            '----------------------------------------------------------
            If res.StartsWith("[") Then
                job.Release
                getma
                Return
            Else If res.StartsWith("{") Then
                Dim record As Map
                record = parser.NextObject 'returns a list with maps
            End If
            '-----------------------------------------------------------------
            val1 = val3 ' ex value
            val2 = val4 ' ex value 1
            val3 = record.get("lastPrice").As(Double) ' new binance
            val4 = getma
            If val4 = 0 Then
                val4 = val2
            End If
            grafico1.NewVal1 = val3           
            grafico1.NewVal3 = val4
            gap = gapMa(val3,val4)
            gapinit(gap)
            grafico1.set4Testi("G: " & gap,"oB: " & val3, "oM: " & val4, "nB: " & val1, "nM: " & val2)
            grafico1.MinMax(record.Get("lowPrice"),record.Get("highPrice"))
            job.Release
            grafico1.disegna
        Else
            job.Release
            getma
        End If
    Catch
        job.Release
        Log("ERROR: JobDone " & LastException)
    End Try
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Just guessing...

"File not found" but also a warning that mentions "illegal access". Maybe you repeatedly, quickly query an online service, requesting files that you download to a temporary folder on the desktop, but they are not sent to you due to illegal access and therefore your project then cannot find them (file not found)?
questo lo avevo capito ma devo risolverlo e certo non aumentando gli intervalli ma trovando il modo corretto per evitare ciò, anche perché e solo job che ha problemi e non le chiamate che il servizio risponde correttamente.

I understood this but I have to solve it and certainly not by increasing the intervals but by finding the correct way to avoid this, also because it is only jobs that have problems and not the calls that the service responds correctly.
 
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
Just a thought
If you change the folder name from 'Trading Forex Maye by Ivano' to just 'Trading' does it make any difference at all?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
understood this but I have to solve it and certainly not by increasing the intervals but by finding the correct way to avoid this, also because it is only jobs that have problems and not the calls that the service responds correctly.
HttpJob class that is part of the OkHttpUtils2 library is actually a b4xlib and therefore you can modify it as per your needs.

In total there are 7 instances in the code where the Tempfolder is used. you have to either substitute it for a better approach on handling the data OR add more randomness to the files that are created there.

but IMO HttpJob is not suited for this kind of work you are doing. All the respectable exchanges have a Websocket connection that is almost instant compared to an http call. Also again most Exchanges will ban you if you make many http calls as you intend. so

correct way
Use Websocket apis for getting the data you need.
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Just a thought
If you change the folder name from 'Trading Forex Maye by Ivano' to just 'Trading' does it make any difference at all?
none, you're right, I put the string at the time of the window title, but thanks for reminding me, I didn't think about it anymore :)
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you still do not seem to get it.
even if you divided everything up into separate threads,
there is no guarantee that threads sent earlier will return
before threads sent later (that's why it's called asynchronous).
you could be quoting prices out of sequence.

and if you try to wait for thread A to finish before thread B
before thread C, etc, then you slowing down the data flow
process and defeating the purpose of threading.

you are not using tcp correctly. i told you 2 weeks ago to use
websockets on your earlier thread
(https://www.b4x.com/android/forum/threads/resolved-problem-jobdone.150836/).
if things did not work at 1 second intervals, they are certainly not going to work at
500 millisecond breaks. this job is not for tcp.

actually, to clarify, this is not a job for http (which uses tcp as its transport layer). maybe http2.
but websockets is designed for this task
 
Last edited:
Upvote 0
Top