Server Connection Question

Hi guys!

Today I decided I want to pull my app from the simulator to my test device, but I encountered a problem:

I don’t know how to connect to a server. I currently have a WAMP installed, and inside the www directory of WAMP a .php file that refers to a database, also stored in WAMP. How can I refer to that php file?

Currently I am using 

[lua]

network.request( “http://localhost/regie/sqlLite.php”, “GET”, networkListener );

[/lua]

what do you guys think?

Can you put that URL in a web browser and have it work?  That’s the best way to make sure your server is setup correctly and that your URL is right.  http://localhost/ is the way to refer to a server running on your computer.  However we have no way of knowing how your system is laid out and if regie is a valid location.   Your PHP might not be running. 

Rob

Yes, it works fine with localhost, but when I replace localhost with my ip adress, it doesn’t work.

From java I remember that I had to work with ports and sockets. Does the same apply here?

What IP address are you trying to use?  Can you hit the URL with your browser with that IP address?

Thanks

Rob

I tried my own public IP address, which i found by typing “ip adress” on google. And no, unfortunately when i try using it in my browser it doesn’t work :frowning:

it looks like 

[lua]

  1. network.request( “http://109.103.xx.xx/regie/sqlLite.php”, “GET”, networkListener );

[/lua]

We really can’t provide you with home networking support.  I don’t know how you have things setup.  But if you are a typical cable modem with a wireless router, your local IP address is more likely a 192.168.1.* address.  The Address you got from that website is the address to your cable modem.  Unless you setup your computer in the DMZ on the router then you won’t be able to use the internet facing IP address.

DMZ setups are not very common and putting your computer in a DMZ opens it up to potential hacking, so unless you understand firewalls, and port management, it’s probably not something you want to tackle.   Look on your device’s network settings and see if you see an 192.168.*.* or 10.*.*.* address.  Those are the two common setups for devices on an internal network.

Rob

Thanks for your reply. I will try this as soon as I get home and I will come back with a response. 

Ok, so now I can access through both my browser and my simulator the required data from the WAMP server

I did this by reaching these steps on stackoverflow:

1-  open that file  C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf

Note  you man have different Apache version than apache2.2.22 so you need to write it instead.

search for:  Directory “C:/wamp/www/”  you will find something similar to this

<Directory “C:/wamp/www/”>

maybe there is some comments here …

AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

be sure that  Allow from all  is exists and not commented

2-  open that file  C:\wamp\alias\phpmyadmin.conf

make sure that

<Directory “C:/wamp/apps/phpmyadmin3.5.1/”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>

change  Allow from 127.0.0.1  to  Allow from all.

 

 

But the problem is not over yet. If i test on my device, this is what happens

Screenshot_2013_12_24_13_08_21_1.jpg

I checked build.settings and the permission is there.

Can you post your build.settings?
 

My build settings:

[lua]

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {

    

    orientation = {

        default = “portrait”,

        supported = { “portrait”, }

    },

    

    iphone = {

        plist = {

            UIStatusBarHidden = false,

            UIPrerenderedIcon = true, – set to false for “shine” overlay

            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            --[[

            – iOS app URL schemes:

            CFBundleURLTypes =

            {

                {

                    CFBundleURLSchemes =

                    {

                        “fbXXXXXXXXXXXXXX”, – example scheme for facebook

                        “coronasdkapp”, – example second scheme

                    }

                }

            }

            --]]

        }

    },

    

    --[[

    – Android permissions

    androidPermissions = {

          “android.permission.INTERNET”,

      },

    ]]–

}

[/lua]

You have the permissions commented out:

&nbsp;&nbsp;&nbsp;&nbsp;--[[&nbsp;&nbsp; --\<----- remove this &nbsp;&nbsp;&nbsp;&nbsp;-- Android permissions &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;androidPermissions = { &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"android.permission.INTERNET", &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;}, &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;]]--&nbsp; --\<------ remove this.

It worked! Sorry for my dumb problem, I didn’t know that those were comments.

Thank you! Now I can continue my work

One more question, i don’t want to open a new thread for this:

Is it possible to control the current image of a button? I mean, my buttons have 2 images: default and onPressed. I want when the user presses the button, the current button image to remain the onPressed image. Otherwise, i should use tiles, or an image sheet or newImageRect, but I want to know if there is a possibility that doesn’t require massive code rewriting

Actually, its better for you to open a new thread.  If someone is searching to find the answer to the question you’re asking and it’s buried in a Networking topic, they won’t find it.  Likewise, if this grows into a longer discussion, someone coming along looking for the networking question will be confused by the topic of buttons.

So please, in the future, open a new one.

The purpose of widget.newButton() isn’t for a “toggle”, its for a button that presses and releases.  If you want a toggle, look at widget.newSwitch() or create your own.

Rob

Can you put that URL in a web browser and have it work?  That’s the best way to make sure your server is setup correctly and that your URL is right.  http://localhost/ is the way to refer to a server running on your computer.  However we have no way of knowing how your system is laid out and if regie is a valid location.   Your PHP might not be running. 

Rob

Yes, it works fine with localhost, but when I replace localhost with my ip adress, it doesn’t work.

From java I remember that I had to work with ports and sockets. Does the same apply here?

What IP address are you trying to use?  Can you hit the URL with your browser with that IP address?

Thanks

Rob

I tried my own public IP address, which i found by typing “ip adress” on google. And no, unfortunately when i try using it in my browser it doesn’t work :frowning:

it looks like 

[lua]

  1. network.request( “http://109.103.xx.xx/regie/sqlLite.php”, “GET”, networkListener );

[/lua]

We really can’t provide you with home networking support.  I don’t know how you have things setup.  But if you are a typical cable modem with a wireless router, your local IP address is more likely a 192.168.1.* address.  The Address you got from that website is the address to your cable modem.  Unless you setup your computer in the DMZ on the router then you won’t be able to use the internet facing IP address.

DMZ setups are not very common and putting your computer in a DMZ opens it up to potential hacking, so unless you understand firewalls, and port management, it’s probably not something you want to tackle.   Look on your device’s network settings and see if you see an 192.168.*.* or 10.*.*.* address.  Those are the two common setups for devices on an internal network.

Rob

Thanks for your reply. I will try this as soon as I get home and I will come back with a response.