title: Getting Android Volley null error after calling specific php functions, other functions work fine
body: <p>I've got an android application which communicates with a webserver using PHP and Volley. My app sends a Post request to a Listener.php file on my webserver and chooses different functions in a Functions.php. The problem is: some functions lead to a volley null error although the code is executed. Theres no error in apache erroglog and I can see the data change in my database. But I want to process a response in my app which is not possible when I get this error. The webserver is running on my raspberry pi now and I get this error all the time when calling specific functions, other functions are working as expected. When I test the same code on Windows its working fine (although these null errors are happening too from time to time at the same functions).
  I really hope theres someone to put me in the right direction, I have no idea how to proceed with that kind of problem..</p>
  <h2>Java/Volley Post</h2>
  <pre><code>  public static void importNewMedia(final Context context) {
  
  
      final String TAG = &quot;importMedia&quot;;
      String tag_string_req = &quot;admin_control&quot;;
      StringRequest strReq = new StringRequest(com.android.volley.Request.Method.POST,
              AppConfig.URL_SERVER, new Response.Listener&lt;String&gt;() {
  
  
  
          @Override
          public void onResponse(String response) {
              Log.d(TAG, response.toString());
              try {
                  JSONObject jObj = new JSONObject(response);
                  boolean error = jObj.getBoolean(&quot;error&quot;);
                  if (!error) {
  
                      Toast.makeText(context, &quot;Database has been updated!&quot;, Toast.LENGTH_SHORT).show();
  
                  } else {
  
                      Toast.makeText(context,
                              &quot;Database has not been updated!&quot;, Toast.LENGTH_SHORT).show();
  
                  }
              } catch (JSONException e) {
  
  
                  Toast.makeText(context, &quot;0&quot;+
                          &quot; Database has not been updated!&quot;, Toast.LENGTH_SHORT).show();
  
  
                  e.printStackTrace();
              }
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              Log.e(TAG, &quot;Connection Error: &quot; + error.getMessage());
  
          }
      }) {
          protected Map&lt;String, String&gt; getParams() {
              HashMap&lt;String ,String&gt; params=new HashMap&lt;String, String&gt;();
              params.put(&quot;tag&quot;, &quot;getNewMedia&quot;);
              return params;
          }
      };
      // Adding request to request queue
      AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
      System.out.println(strReq + tag_string_req);
  
  
  }
  </code></pre>
  <h2>Listener.php</h2>
  <pre><code>else if ($tag == 'getNewMedia') {    
  
      $db_functions-&gt;copyNewMediaToSongs($mysqli);
          
       if ($test ) {
  
          $response[&quot;error&quot;] = FALSE;
          echo json_encode($response);
          
          
      } else {
     
          $response[&quot;error&quot;] = TRUE;
          $response[&quot;error_msg&quot;] = &quot;Server Error&quot;;
          echo json_encode(array_values($response));
      }
  } 
  </code></pre>
  <h2>One of the Functions that causes null error</h2>
  <pre><code>  public function copyNewMediaToSongs($mysqli) {
  
  
     shell_exec('sudo sh /var/www/html/musicbox/include/findmp3.sh');
     return 1;
  
     }
  </code></pre>
  <h2>What Logcat shows me ...</h2>
  <p>08-09 04:16:01.420 2812-2979/com.ruecgames.sengproject.musicbox I/System.out: [ ] <a href="http://192.168.2.123/musicbox/include/Listener.php" rel="nofollow noreferrer">http://192.168.2.123/musicbox/include/Listener.php</a> 0x85ca2597 NORMAL 18admin_control
  08-09 04:16:09.008 2812-2812/com.ruecgames.sengproject.musicbox             E/getConfig: Connection Error: null</p>