• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

HTTPREQUEST on Android

Wopag

New member
Joined
Aug 19, 2017
Messages
7
Well finally decided to ditch monkey1, monkey2 is going nowhere quickly so here I am :)

Impressive amount of work done to keep such a good language alive !!!!! Been lurking for ages but Ive hung onto Monkey2 being my savior (which its not)


So small problem (now I have everything installed), Ive taken a working Monkey app and compiled in Cerberus, all good. Works fine as HTML and DESKTOP but breaks in Android.

Its a simple http request and display on screen using OnHttpRequestComplete:Void(req:HttpRequest)


In android it seems that the "responsetext" is returning NULL - when its defined as a string and cant be a NULL. ( this is after issuing New HttpRequest(....) )


I have noticed an error on compile :-
"
Note: D:\Dropbox\test\monkey\it\lean.buildv2019-05-05\android\app\src\main\java\net\app\test\CerberusGame.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Dropbox\test\monkey\it\lean.buildv2019-05-05\android\app\src\main\java\net\app\test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."

Is there a problem with the native android http request ?


/Stu
 
Hi and welcome to the forum. You are the first to report that. Will have a look.
 
After I posted I found those 2 threads (sorry)

I have been having a look seems this is at fault :- ( this is in httprequest.android.java )

Code:
void Run__UNSAFE__(){
        try{
       
            System.out.print("Send text = "); 
            System.out.print(_sendText);
            System.out.print(" ===========");
       
            _response = "empty";     <<<<<< this will stop returning a null
       
            if( _sendText !=  null )
            {
   
              
               System.out.print("THIS IS NOT RUNNING");
          
                byte[] bytes=_sendText.getBytes( "UTF-8" );

                _con.setDoOutput( true );
                _con.setFixedLengthStreamingMode( bytes.length );
              
                OutputStream out=_con.getOutputStream();
                out.write( bytes,0,bytes.length );
                out.close();
            }
          
           System.out.print("this runs");

            InputStream in=_con.getInputStream();

           System.out.print("this does not");

Just checked on a local http server - it never receives a connection from the android phone.

ok more checking InputStream in=_con.getInputStream(); seems the culprit ......... could this be because the connection is not established first?


The connection code run without error - unless its the connectivitymanager not being set correctly ?

Code:
void Open( String req,String url,int timeout,boolean httpsVerifyCertificate, boolean httpsVerifyHost ){
        try{
            ConnectivityManager connMgr = (ConnectivityManager)BBAndroidGame.AndroidGame().GetActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
            
            
            
            if( networkInfo != null && networkInfo.isConnected() )
            {
                URL turl=new URL( url );
                _con=(HttpURLConnection)turl.openConnection();
                _con.setRequestMethod( req );
                _con.setConnectTimeout(timeout);
                _con.setReadTimeout(timeout);
                _status = 1;
                
            }
    }
    catch( Exception ex ){
      _response="";
      _status=-1;
      _recv=0;
    }
  }
 
Last edited:
yes they still are.

but then my native version of the http stuff is different to what we have in Cerberus. can't remember the last time I updated monkeyx
 
I do see another error ,

Code:
(HTTPLog)-Static: isSBSettingEnabled false
 
I can confirm, it is a bug and i will try to fix it. Wish me luck.
 
Last edited:
Ok, I have to take this back. So far all the https requests I do on GLFW, HTML and Android behave the same.

but then my native version of the http stuff is different to what we have in Cerberus. can't remember the last time I updated monkeyx
Yes, we have updated the native code to do httprequest with https connection. These imho are standard these days.

I have been having a look seems this is at fault :- ( this is in httprequest.android.java )

Code:
void Run__UNSAFE__(){
try{

System.out.print("Send text = ");
System.out.print(_sendText);
System.out.print(" ===========");

_response = "empty"; <<<<<< this will stop returning a null

if( _sendText != null )
{


System.out.print("THIS IS NOT RUNNING");

byte[] bytes=_sendText.getBytes( "UTF-8" );

_con.setDoOutput( true );
_con.setFixedLengthStreamingMode( bytes.length );

OutputStream out=_con.getOutputStream();
out.write( bytes,0,bytes.length );
out.close();
}

System.out.print("this runs");

InputStream in=_con.getInputStream();

System.out.print("this does not");
Just checked on a local http server - it never receives a connection from the android phone.

That totally doesn't look like the code we ship. And how do you test with a local http server?
 
Revisited this thread......

Using the example/mak/httprequest - using a new PC - just cerberusX loaded - output to Android.

Changing the HTTPS to HTTP and directing it to a local web sever on the same Ip range (192.168.0.X) results in no connection

Code:
08-16 13:02:06.314 14878 14899 I [Cerberus]: Http GET complete!
08-16 13:02:06.314 14878 14899 I [Cerberus]: Status=1
08-16 13:02:06.315 14878 14899 I [Cerberus]: ResponseText=null
08-16 13:02:06.315 14878 14899 I [Cerberus]: Http POST complete!
08-16 13:02:06.315 14878 14899 I [Cerberus]: Status=1
08-16 13:02:06.315 14878 14899 I [Cerberus]: ResponseText=null
 
If I run the example as a desktop Glfw3 just crashes

Code:
TRANS cerberus compiler V2019-02-21
Parsing...
Semanting...
Translating...
Building...
g++  -m64  -O3 -DNDEBUG -Wno-free-nonheap-object -I../curl/include -I../glfw3/include -I../glfw3/src -I../openal/include -I../stb -I../zlib-1.2.8 -I../lpng1610 -c -o build/Release64/main.o ../main.cpp
g++ -m64  -s -LC:/Cerberus/libs/Win64 -Wl,--subsystem,windows -o Release64/CerberusGame build/Release64/context.o build/Release64/egl_context.o build/Release64/init.o build/Release64/input.o build/Release64/monitor.o build/Release64/osmesa_context.o build/Release64/vulkan.o build/Release64/wgl_context.o build/Release64/win32_init.o build/Release64/win32_joystick.o build/Release64/win32_monitor.o build/Release64/win32_time.o build/Release64/win32_thread.o build/Release64/win32_window.o build/Release64/window.o build/Release64/stb_vorbis.o build/Release64/stb_image.o build/Release64/resource.o build/Release64/main.o -lcomdlg32 -lgdi32 -lopengl32 -lopenal32 -lcurldll -lws2_32

Cerberus Runtime Error : Memory access violation
(null)
STOPPED
 
Back
Top Bottom