storageService insertJSONDocument problem

0 votes

After perform insertJSONDocument I wait 2min and perform insertJSONDocument again then I get  "Please check your network connection" message.

I get this error message only in the device (it works in the simulator)

SDK: Corona SDK
Plataform: Samsung S3
 

Code Example:

require("App42-Lua-API.Operator")  
require("App42-Lua-API.Permission")  
require("App42-Lua-API.GeoOperator")  
require("App42-Lua-API.OrderByType")  
require("App42-Lua-API.Operator")  
local JSON = require("App42-Lua-API.JSON")   
local queryBuilder = require("App42-Lua-API.QueryBuilder")  
local App42API = require("App42-Lua-API.App42API")  
local ACL = require("App42-Lua-API.ACL")

local function insertDoc( event )

    local dbName  = "places"  
    local collectionName = "myplaces"  
    local json = "{\"name\":\"Nick\",\"age\":30,\"phone\":\"xxx-xxx-xxx\"}"  

    local App42CallBack = {}  
  

    App42API:initialize("xxx","xxx")    
    local storageService = App42API:buildStorageService()  
    print("insert")
    storageService:insertJSONDocument(dbName, collectionName, json,App42CallBack)  
    function App42CallBack:onSuccess(object)  
        print("dbName is "..object:getDbName())  
        print("collectionName is "..object:getCollectionName())  
        print("DocId is "..object:getJsonDocList():getDocId())  
        print("Created At is "..object:getJsonDocList():getCreatedAt())  
        print("Updated At is "..object:getJsonDocList():getUpdatedAt())  
    end  
    function App42CallBack:onException(exception)  
        print("Message is : "..exception:getMessage())  
        print("App Error code is : "..exception:getAppErrorCode())  
        print("Http Error code is "..exception:getHttpErrorCode())  
        print("Detail is : "..exception:getDetails())  
    end  
end

insertDoc()
timer.performWithDelay( 120000, insertDoc )

Console:

V/Corona  (28780): > Class.forName: network.LuaLoader
V/Corona  (28780): < Class.forName: network.LuaLoader
V/Corona  (28780): Loading via reflection: network.LuaLoader
I/Corona  (28780): Platform: GT-I9300 / ARM Neon / 4.3 / Mali-400 MP / OpenGL ES 2.0 / 2015.2646
V/Corona  (28780): > Class.forName: plugin.fuse.LuaLoader
V/Corona  (28780): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (28780): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (28780): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
I/Corona  (28780): insert
I/Corona  (28780): dbName is places
I/Corona  (28780): collectionName is myplaces
I/Corona  (28780): DocId is 55dd93b7e4b0749cc5d69511
I/Corona  (28780): Created At is 2015-08-26T10:23:51.951Z
I/Corona  (28780): Updated At is 2015-08-26T10:23:51.951Z
I/Corona  (28780): insert
E/Corona  (28780): ERROR: null
I/Corona  (28780): Message is : Please check your network connection
I/Corona  (28780): App Error code is : null
I/Corona  (28780): Http Error code is null
I/Corona  (28780): Detail is : null

 

Thank you.
Best Regards.

 

asked Aug 26, 2015 in App42 Cloud API-BaaS by germanfv (18 points)

1 Answer

0 votes
Hello,

Its look like your device is not able to connect to internet. Please make sure that your device have internet connection available. Because client itself throwing this exception which you can see in RestConnector.lua file.

Let me know if it helps.  

Regards,

Himanshu Sharma
answered Aug 26, 2015 by hs00105 (2,005 points)
Hello!

Internet connection is working.

It seems to be a known issue with corona sdk and android:

I found this answer:

"It's a know issue on Android 4.3 with network POST. It is very sensitive and will sometimes drop network requests. You should have a retry implemented"

https://forums.coronalabs.com/topic/45112-whats-error-null-for-android-device-console-log/

I will try to implement a retry.

Thank you,

Best Regards,
German.
Hello,

Thanks for sharing the post with us. Could you please let us know in which version of corona sdk you are working on? Meanwhile we can also work on that. Who ever made first will share here, so that it will help other as well.

Regards
Himanshu sharma
I was working in Corona latest Public Release 2015.2646.
I tried it also in latest Daily Build 2015.2702 and I had the same network problem

I found another post. The moderator wrote in it.
It seems could be another reasons that cause the problem.

https://forums.coronalabs.com/topic/45069-android-network-requests-random-no-responses-and-no-response-with-https/

Regards,
German
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...