iOS Question Why does b4i refuse to establish connection to MySql server?

Status
Not open for further replies.

jkhazraji

Active Member
Licensed User
Longtime User
Why does b4i refuse to establish connection to MySql server? whether remote one or local host, by using the iHttp and iHttpUtils libraries?
..what is wrong?

B4X:
Process_Globals
.
.
.

Dim iJob As HttpJob
End Sub

Sub connect()
.
.
iJob.Initialize("MyJob",Me)
.
.
  
  iJob.Download2("https://192.168.0.21/DBDir/phpfile.php",Array As String( "key1","val1",  "key2","val1","key3","val3") )
    iJob.GetRequest.SetContentType("text/plain")
End sub

Sub JobDone(Job as HttpJob)
 
    If Job.Success Then

    Dim res As String
     res = Job.GetString
    Dim parser As JSONParser
    parser.Initialize(res)
    Select Job.JobName
            Case "MyJob"
             Dim NAMES As List= parser.NextArray 'returns a list with maps
                For i = 0 To NAMES.Size - 1
                    Dim m As Map
                    m = NAMES.Get(i)
           
             '.....
           log(m.Get("index"))
             Next
   End Select
    Else
        Log("Error ocurred:" & Job.ErrorMessage)
        
    End If
    Job.Release
 .
 .

End Sub
 

OliverA

Expert
Licensed User
Longtime User
1) localhost is NOT the name of the server. The term localhost should always resolve to 127.0.0.1, which is whatever device your on (on your windows machine, it will be your windows machine, on your android device it will be your android device, and on the iphone/pad/etc it will be that device).

2) So after disabling ATS and using this
B4X:
iJob.Download2("http://192.168.0.21/DBDir/phpfile.php",Array As String( "key1","val1",  "key2","val1","key3","val3") )
, what is your error message? Are you sure you can connect to that site with your iPhone using Safari and you are actually using this URL on your phone: http://192.168.0.21/DBDir/phpfile.php?key1=val1&key2=val1&key3=val3? Screenshot please!
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
Sorry for making myself unclear. Here is the code that did not work on b4i.
 

Attachments

  • b4icode.zip
    4.8 KB · Views: 216
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
@OliverA
The error is:'unknown error code:0'
Attached is a screenshot as you requested..regards
 

Attachments

  • sshot.png
    72.4 KB · Views: 209
Upvote 0

OliverA

Expert
Licensed User
Longtime User
1)
Attached is a screenshot as you requested..regards
Yes, but you did not follow instructions! You performed the browser action on the Windows PC, not on the Phone/Device that you are installing the app on! I want you to use Safari on the device you will be installing/have installed the app on and go the the above URL (see post #21). Take a screenshot of the result.

2) Regarding your source: Why are you including the source code of the iHttpUtils2 library (and iHTTP?)? Are you modifying it in some sense, or are you using a really old B4i that does not include it as a library in the IDE? Why would you name your MAIN project source file the same name as a library?
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
1- A screenshot of Safari on my iphone is attached. The ip is of hotspot I use it inside the app.
2- I think I can use the Httputils2 library or its source code to achieve the same purpose. I did not modify its source code.
 

Attachments

  • sshot2.png
    61.5 KB · Views: 216
Upvote 0

OliverA

Expert
Licensed User
Longtime User
1) Why are you using a hotspot? You should be connected wireless to the same network that your PC is connected to! Not being connected to the same network will produce a whole lot of other issues that have nothing to do with your app. Even the hotspot usage has nothing to do with your app. We need to get all roadblocks out of the way and get the app working with your PHP host without any extra layers in the way. The IP address for you phone needs to be (if your machine hosting the PHP script is 192.168.0.21) a 192.168.0.x number where x is > 0 and < 255. Then try to URL above and give a screenshot of Safari with the URL in Safari's URL bar with the corresponding result after browsing to the URL using Safari.
2) Do not include the source of the libs and do not, if at all possible, name your main project file the same as one of the libs. Rename your project to something else (if need, create a new one and copy source over, and change ATS setting).
3) We really need to get #1 working first or time is just being wasted.

Edit: Add a screenshot of your phone's IP address.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This thread is a good example of how not to ask a question.

If you want the community to help you then provide accurate information and answer the questions asked. It is not our job to guess what you are doing and it seems like you are ignoring our requests for more information.

This thread is locked. You can start a new one. I will not participate in it but maybe other good members such as OliverA will.
 
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…