16 Replies Latest reply on Aug 15, 2011 4:03 PM by wolf14

    AIR doesn't communicate with my server - PHP issue

    wolf14 Level 1

      Hello,

       

      So I have made an AIR application where the file communicates with a PHP file in order to display data.

      I have WAMP installed on my computer, and the application works when I test locally using WAMP but if I upload the php on an online server(I tried on two of my servers) and run the AIR application it seems that it doesn't communicate with the server so no data are displayed.

       

      var url:URLRequest = new URLRequest("http://www.test.com/test.php")


      This is how I call for the php on AS3, like shown above.

      Any suggestions?

       

      The php file gives no errors when I browse it online so, I suppose there something else going on?

        • 1. Re: AIR doesn't communicate with my server - PHP issue
          Joe ... Ward Level 4

          Use something like wireshark to monitor your network connection to make sure the request is getting sent and see if there is a response. Also check the server and error logs on your PHP server.

          1 person found this helpful
          • 2. Re: AIR doesn't communicate with my server - PHP issue
            wolf14 Level 1

            I think the request is not even sent, because it immediately the displays the Error I have set. When testing using wamp, it takes few sec to communicate then displays the data. When testing online though it displays the error after you hit the button...

            • 3. Re: AIR doesn't communicate with my server - PHP issue
              wolf14 Level 1

              So can anyone determine the reason of this issue? Or atleast point me to a direction so I can fix it?

              What could be causing this communcation issue between the server and the air application? Maybe application permissions?

              As I said it works fine when using WAMP for testing php locally...

              • 4. Re: AIR doesn't communicate with my server - PHP issue
                Joe ... Ward Level 4

                That the request fails quickly probably indicates that the network stack on your computer can't resolve the URL -- this would be a fast failure since there's no timeout to wait for.

                 

                Are you listening for IO errors on the object responsible for making the connection?

                 

                There are no application permissions on the desktop. If your code is running outside the AIR application sandbox, then some security issues would come into play. This could happen if you are loading SWF or HTML files from outside the application directory.

                • 5. Re: AIR doesn't communicate with my server - PHP issue
                  wolf14 Level 1

                  There are no errors, on either the php files stored online neither the flash swf.

                  The only file scalled from an online server are the PHP.


                  I suppose I don't need to pack these PHP when publishing the air file, since they need to be called from an online server?

                  Very tricky since there are no errors, I would appreciate any help since this is an urgent project.

                   

                  //EDIT:

                   

                  So I just removed the http:// from the urlrequest to the site that the PHP is stored and I get this IO error:

                   

                  Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: app:/test.com/test.php

                  at my_fla::test_1/setPHP()[my_fla.test_1::frame1:38]

                  Notice the app:/ ? why is it there? Could it be the issue? I am not sure, but if you link to a local file, like "test.php" it works, but when adding a URL it doesn't...
                  • 6. Re: AIR doesn't communicate with my server - PHP issue
                    Joe ... Ward Level 4

                    When you remove "http://" the runtime thinks you are using a relative URL and tries to open that URL as a local file. Anything in the application directory gets the app: scheme instead of the file: scheme.

                     

                    What happens when you open your "test.com/test.php" URL with a browser?

                     

                    "I suppose I don't need to pack these PHP when publishing the air file, since they need to be called from an online server?"

                    Correct.

                    1 person found this helpful
                    • 7. Re: AIR doesn't communicate with my server - PHP issue
                      wolf14 Level 1

                      When browsing the PHP's online the page is blank.

                      On the first PHP though there is text displayed on the screen, because I have set some text echo on the PHP so there are no errors displayed.

                      • 8. Re: AIR doesn't communicate with my server - PHP issue
                        Joe ... Ward Level 4

                        Since you aren't getting an IO error from the remote request (with http://), then you should be getting a response from the server. Do you get httpResponseStatus or httpStatus events dispatched by your URLLoader object?

                        • 9. Re: AIR doesn't communicate with my server - PHP issue
                          wolf14 Level 1

                          No, as I said the error only comes when not using the "http://".

                          I get no errors when using the whole url. But the data is not displayed.

                           

                          Maybe it's php server settings issue? If you have a spare server for testing maybe I could send you the php so we can test it out?

                          • 10. Re: AIR doesn't communicate with my server - PHP issue
                            Joe ... Ward Level 4

                            It seems the most likely issue is that you are getting a response from the server that isn't what you are expecting. If you weren't getting a response at all, you would get an IO error. So your next step should be to examine the response (status code, headers, etc) and determine what is wrong with it. You can use the Flash API status events to examine this info from inside your app, or something like Wireshark to examine the network traffic between your app and the server.

                             

                            (Sorry, I don't have a publically available PHP server.)

                            • 11. Re: AIR doesn't communicate with my server - PHP issue
                              wolf14 Level 1

                              Ok, so I am trying to do that with wireshark. I go to Capture options, select my .air application and hit start?

                              Then when I hit the button(in the air app) that makes the communication there are few lines displayed on wireshark, what exactly am I looking for?

                              • 12. Re: AIR doesn't communicate with my server - PHP issue
                                Joe ... Ward Level 4

                                Filter the Wireshark display for HTTP traffic (you can use ip.addr -- {whatever the server ip is} to show just traffic between the server and the app).

                                When you click your button, you should see a GET or POST request from your computers IP to the server IP

                                Shortly thereafter, you should see a response from the server to your computer.

                                When you click on the response line in the Wireshark display, it will show the data in that response.

                                 

                                If the data you expect is missing, then it is a problem on the server (since you said the same code worked on the local server).

                                • 13. Re: AIR doesn't communicate with my server - PHP issue
                                  wolf14 Level 1

                                  Ok, so it seems there is a POST(which includes my PHP in the info) from my computer to the Server and after that, the Server tries to communicate with my computer as shown on Wireshark but there is no GET or data shown on it. Show I suppose the issue is sending the data from the server to my computer.

                                   

                                  Now the question is, how can I fix this?

                                   

                                  One note is that on the PHP I have a request for a second PHP which is also stored on the server, I don't see wireshark mentioning it though. It only shows POST from the first PHP file.

                                  • 14. Re: AIR doesn't communicate with my server - PHP issue
                                    wolf14 Level 1

                                    By the way do I have to create any databases or edit apache options etc, on my server in order to make the php files to work? What I did is simply upload them on the server using the file manager, maybe that's why there is a communication issue?

                                     

                                    Also can you describe how I can check the communication by using the Flash API like you said?

                                    • 15. Re: AIR doesn't communicate with my server - PHP issue
                                      Joe ... Ward Level 4

                                      Yes, you have to enable PHP in the Apache config and setup any databases and database connections you need (I'm not the person to ask about such details, though).

                                       

                                      For the Flash APIs I mentioned, just add event listeners to the URLLoader that you use to send the POST request and examine the results.

                                      • 16. Re: AIR doesn't communicate with my server - PHP issue
                                        wolf14 Level 1

                                        OK so I suppose the issue is that the server is not setup properly to accept the php communication.

                                        If anyone can help me out set it up, my host has a cPanel X. Please let me know how to set it properly to allow the php communication.

                                         

                                        Also thanks a lot to Joe for being so helpful.