1 Replies - 335 Views - Last Post: 21 September 2019 - 05:01 PM

#1 TheStudent555   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-February 19

Android application not able to connect to server

Posted 19 September 2019 - 06:03 PM

My application is not able to connect to the web server. I am currently using volley to make network calls. My Android Manifest has the following
   <uses-permission android:name="android.permission.INTERNET" />



Below is the Java Volley network call

public Network(Context context){
 this.requestQueue = com.android.volley.toolbox.Volley.newRequestQueue(context);

}

public void NetworkCall(){
      json_request = new JsonObjectRequest(Request.Method.POST, this.url, this.json_object, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {

                json_object_response = response;
                Log.d(TAG, "Network success! : " + response.toString());
                counter++;
            }
        }, new Response.ErrorListener() {
            @Override
            public void onerrorResponse(VolleyError error) {

                Log.d(TAG, "Network Error " + error.getMessage());
            }
        });

        requestQueue.add(json_request);


        return json_object_response;
}




json_object_response
Returns null when the above function gets called. Both functions onResponse and ErrorListener never get called.

Tried using HttpURLConnection to make network calls but end up with the following error

W/System.err: java.net.SocketTimeoutException: failed to connect to /192.168.1.141 (port 80) after 10000ms



Which leads me to believe the WAMP server is not on the LAN. However, I have taken measures to put the server on the local network by modifying httpd-vhost.conf file.

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "C:/Web"
  <Directory "C:/Web/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>



Changed the httpd-vhost.conf file from Require local -> Require all granted

I even modified the httpd.conf
ServerName 192.168.1.141:80



Listen 192.168.1.141:80



Then restarted the server to no success.

Does anyone know what the problem might be? Am I missing something? How do I know if my WAMP server is on the local network (LAN)?

Is This A Good Question/Topic? 0
  • +

Replies To: Android application not able to connect to server

#2 TheStudent555   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-February 19

Re: Android application not able to connect to server

Posted 21 September 2019 - 05:01 PM

Managed to fix the connection when it comes to browser to server connection by adjusting my firewall . But the android app from the physical device still cannot make a network call. The volley code and the HttpURLConnection will not run. However, the Chrome app on the device does reach server. What could be causing this?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1