B4J Question [ABMaterial] Old Android Phone

PCastagnetti

Member
Licensed User
Longtime User
On an old Android smartphone using the stock browser I always get this error (Ver 2.03).

java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
Disconnected
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
Disconnected
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:190)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
... 15 more
.......
.....
......
.....
This happens before the WebSocket_Connected event.
The real problem is that you enter into a loop of disconnections.
Is there a way to identify such browsers and eventually send an error message to the user?

Thank you
 

mindful

Active Member
Licensed User
This happens only on that phone ? Does it work from the pc or from other phone ? If so try to clear the cache of the browser. also could be usefull to add DateTime.Now as the value of AppVersion in ABMShared in Process_Global (Public AppVersion As String = DateTime.Now) ... if you did all this and still doesn't work it could be usefull to post the code from the WebSocket_Connected ... but more likely is probably you updated to the ABMaterial 2.03 and did not clear the cache from the browser (which uses the old reconnection method)
 
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
This happens only on that phone ? Does it work from the pc or from other phone ?

Only on this phone and only with the Stock browser (chrome works).

I also tried with the demo project of Ver. 2.03 and the behavior is the same.

The disconnection occurs in this line of ABMApplication
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    Log("Connected")
    ws = WebSocket1
  
  
      
    AppPage.SetWebSocket(ws)  '--> disconnection



I also encountered this error condition, which appears sometimes only in debug mode

Error occurred on line: 95
java.lang.RuntimeException: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
at anywheresoftware.b4j.object.WebSocket.get(WebSocket.java:120)
at anywheresoftware.b4j.object.WebSocket.EvalWithResult(WebSocket.java:330)
at com.ab.abmaterial.ABMaterial.getUUID(Unknown Source)
at com.ab.abmaterial.ABMPage.SetWebsocket(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:656)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:232)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:192)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at italretail.prenota.main.main(main.java:29)
Caused by: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
at org.eclipse.jetty.websocket.common.WebSocketSession.getRemote(WebSocketSession.java:299)
at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
at anywheresoftware.b4j.object.WebSocket.get(WebSocket.java:117)
... 31 more




thank you
 
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
some more elements ...
I tried on 3 devices with Android stock browser (see image), trying to open the project DemoDynamic Ver 2.03 but it failed on all devices (1 with Android 5).

I try to do a downgrade to version 2.00 and resolves the issue.

Thank you
 

Attachments

  • Screenshot_2016-11-25-18-02-50.png
    Screenshot_2016-11-25-18-02-50.png
    94.8 KB · Views: 230
Last edited:
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
if it can help, I attach the log files (Demo project Ver 2.03)
 

Attachments

  • logs.txt
    4.7 KB · Views: 251
  • b4j-2016_11_25.request.log.txt
    185.6 KB · Views: 235
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
On an old Android smartphone using the stock browser I always get this error (Ver 2.03).


This happens before the WebSocket_Connected event.
The real problem is that you enter into a loop of disconnections.
Is there a way to identify such browsers and eventually send an error message to the user?

Thank you

What's the make and model phone? Is it running the AOSP edition of Android?

.
 
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
What's the make and model phone? Is it running the AOSP edition of Android?
only one of the phones that I used for testing has the AOSP edition of Android
The problem seems to be related to the browser and not the operating system.

In my opinion the solution would be to send a message 'browser not supported' and avoid the loop of connection and reconnection.
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
Hi i have this error
in ABMApplication after buildpage function...
this occours inside a webview android object on os version 4.4
in android 6 it works correctly
i thonk thak http://www.schedule-analytics.com/analytics.js
called inside this function
B4X:
/* Analytics
   ================================================== */
   _initGoogleAnalytics: function() {
     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

     ga('create', this.options.ga_property_id, 'auto');
   },
in timeline.js javascript

B4X:
<html>
  
<head>

    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

  
<title>Schedule-Analytics.com</title>

<meta name="keywords" content="cash advance debt consolidation insurance schedule-analytics.com" />

<meta name="description" content="Find Cash Advance, Debt Consolidation and more at Schedule-Analytics.com. Get the best of Insurance or Free Credit Report, browse our section on Cell Phones or learn about Life Insurance. Schedule-Analytics.com is the site for Cash Advance." />

<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
<script language='JavaScript' src='/js/standard.js?rte=1&tm=2&dn=schedule-analytics.com&tid=1020'></script>

<meta name='google' value='notranslate' />
<script type='text/javascript' language='JavaScript' src='/js/google_caf.js?rte=1&tm=2&dn=schedule-analytics.com&tid=1020'></script>
<script type='text/javascript' language='JavaScript' src='http://www.google.com/adsense/domains/caf.js'></script>

<script type='text/javascript'>
var pageOptions =
{
    'domainRegistrant' : 'as-drid-2421601518898051',
    'relatedSearchBaseUrl': 'http://www.schedule-analytics.com/?ac=2&slt=8&slr=1&lpt=1',
    'resultsPageBaseUrl': 'http://www.schedule-analytics.com/?ac=2&slt=8&slr=1&lpt=1',
    'pageLoadedCallback': google_callback,
    'pubId': 'dp-demandmedia_test_js',
    'channel': '000001',
    'terms': '',
    'optimizeTerms': true,
    'uiOptimize' : true,
    'adtest': 'off',
    'hl': 'it'
};

var searchboxBlock =
{
    'container': 'searchbox',
    'type': 'searchbox',
    'width': '300px',
    'widthSearchButton': 70,
    'colorBackground': 'transparent',
    'colorSearchButton': '#17181A',
    'colorSearchButtonText': '#B4EC6A',
    'fontSizeSearchInput': 16,
    'fontSizeSearchButton': 16,
    'hideSearchInputBorder': true,
    'hideSearchButtonBorder': true
};

var rsblock1 =
{
    'container': 'searchLinks',
    'type': 'relatedsearch',
    'number': 10,
    'columns': 2,
    'adIconUrl': '//afs.googleusercontent.com/dp-demandmedia/t1020/bullet-green-arrow.png',
    'adIconWidth': 20,
    'adIconHeight': 20,
    'adIconSpacingAbove': 15,
    'adIconSpacingBefore': 2,
    'adIconSpacingAfter': 10,
    'colorBackground': 'transparent',
    'fontFamilyAttribution': 'arial',
    'fontSizeAttribution': 18,
    'colorAttribution': '#999999',
    'attributionBold': 'false',
    'fontFamily': 'arial',
    'fontSizeTitle': 24,
    'colorTitleLink': '#9FD801',
    'rolloverLinkColor': '#E57921',
    'rolloverLinkUnderline': true,
    'noTitleUnderline': true,
    'titleBold': true,
    'lineHeightTitle': 50,
    'verticalSpacing': 2
};


var parkingData =
{
    'pageType': '1',
    'googleStatus': 'Clean',
    'cacheKey': '00000000-0000-0000-0000-000000000000',
    'clientIPHash': '-1844452700',
    'userAgentHash': '-1935063096',
    'time': '11/28/2016 2:25:44 AM',
    'ticks': '636158967440501659',
    'domainName': 'schedule-analytics.com',
    'searchText': '',
    'actionCode': 'InitialView',
    'adNetworkID': '260',
    'moduleID': '29',
    'resultLinkType': '5',
    'webLinkType': 'GoogleWeb',
    'vipIP': '98.124.243.39',
    'sessionID': '8af320df-3900-4565-ac79-4072b67b67a4',
    'visitorID': 'c1878f9c-67b6-4515-b08f-dbdaae26fd5f',
    'ippiClassification': '4',
    'requestGuid': 'bc14bd2f-7da0-4fc1-aead-b9f74ea143fe',
    'searchLinkType': 'Unknown',
    'templateID': '1020',
    'themeID': '220538',
    'pageUrl': '/analytics.js',
    'searchLinkRank': '0',
    'referrer': 'http://172.16.10.153:51045/demo/AboutPage/abmaterial-about.html?1480326946941',
    'referrerSearchText': '',
    'subID': '0',
    'searchLinkAreas':
    [
        {
            'maxCount': 10,
            'divID': 'sec_20',
            'class': 'rs',
            'headerText': 'Related Searches'
        }
    ],
    'apiIteration': 0,
    'mobileBrowserType': 4,
    'adLineFormat': 3,
    'wClass': 'wr',
    'terms': '',
    'adHeader': 'Sponsored Listings'
};

new google.ads.domains.Caf(pageOptions, searchboxBlock, rsblock1);
</script>


      
    <title></title>      
    <link href="/css/style.css?rte=1&tm=2&dn=schedule-analytics.com&tid=1020&def=Akamai%3aHostingURL%3dhttp%3a%2f%2fi.nuseek.com" rel="stylesheet" type="text/css" />  

</head>
  

<body id="lander"  class='caf'>

<form id="parking_form" method="get" action="/default.php">


<!--
=================================================
** START DEBUG OUTPUT                          **
=================================================
             Version: 3.7.171.1
     Logging_Version: 3.6
           Webserver: 2202B
           Client_IP: 89.96.101.231
              VIP_IP: 98.124.243.39
           HTTP_Host: www.schedule-analytics.com
         Domain_Name: schedule-analytics.com
  Total_Process_Time: 15ms
       MemCache_Time: 8ms (52%)
       Database_Time: 3ms (22%)
            API_Time: 2ms (14%)
=================================================
** END DEBUG OUTPUT                            **
=================================================
-->



<div class="customHdr"></div>  

<div class="wrapper">

<div class="header">

    <div class='pageHeader'><h1>Schedule-Analytics.com</h1></div>

    <div id='searchbox' class='searchBox'>
</div>
  

    <div style="clear:both;"></div>

</div>


<div class="content">

    <div class="colFluidLander">
        <div id='searchLinks' class='rs'></div>      
        <div style="clear:both;"></div>
    </div>

         

</div>


<div class="footer">

    <div class="customFtr"><div class="renewalText">
    <p style="margin:10px 0;">
    This Domain Name Has Expired - <a href="/renewal.aspx" target="_blank">Renewal Instructions.</a>   
    </p>
</div></div>  

    <div class='legal'><a href='http://whoisprivacyprotect.com/terms/privacy.html' target='_blank'>Privacy Policy</a></div>

</div>

</div><!-- end .wrapper -->


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-2249740-15");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2249740-16");
pageTracker._initData();
pageTracker._trackPageview();
</script>




</form>        
  
</body>
</html>
 

Attachments

  • helpme2.png
    helpme2.png
    403.6 KB · Views: 251
  • helpme.png
    helpme.png
    268.8 KB · Views: 247
Last edited:
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
You can test with "Andy" the Android Emulator. I still have Andy running Jelly Bean (4.2.2) loaded.

Follow this link to download the 4.2.2 installer.

Andy 4.2.2 (JellyBean)
https://www.macthomasengineering.com/andy/andy_v42_10_jan2015.zip

Or you can get the latest at the main site http://andyroid.net/

Agent Info

Your User Agent is:

Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; GT-P5200 Build/JDQ39E) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

2_andy_user_agent_zpsd9lj9k1n.jpg


Agent above reported running the default Android browser.

1_andy_browser_zpsvy9tamjj.jpg


ABMaterial Demo through Andy

3_andy_abm_zpsc9imqehp.jpg


.
 
Last edited:
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
Can you send me how your user agent looks like (in the Android Stock Browser)?

Surf to http://www.whoishostingthis.com/tools/user-agent/

It appears the only way so get any further on this is finding a way to detect if the stock browser engine is used.

Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; GT-P5200 Build/JDQ39E) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
@stanmiller Thanks for the tip on Andy!

No support for Websockets is also catched in ABMaterial.

The problem:

We have three type of websockets.

Normal WebSocket (works fine on everything, except it does not reconnect)
ReconnectingWebSocket (sub class of WebSocket, causes some problems on Ipads and IPhones, works fine on the rest)
RobustWebSocket (sub class of WebSocket, causes problems on Android Stock Browser, fine on the rest)
 
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
Can you send me how your user agent looks like (in the Android Stock Browser)?

In the file b4j-2016_11_25.request.log.txt (in post #8) you can find the user agent of 3 different devices:
127.0.0.1 = windows machine with chrome
192.168.0.191= old phone with Android stock browser
192.168.0.230= Android x86 virtualbox (Ver 4.4) with stock browser
 

Attachments

  • Screenshot_2016-11-28-21-16-11.png
    Screenshot_2016-11-28-21-16-11.png
    172.8 KB · Views: 227
Upvote 0
Top