pudd1nG's avatar

Intermitant no response from POST request.

Hello, I've got the most basic app in the world running on lumen.

It has one route which is a POST

$app->post('/forms/crm/public/contact', 'ContactController@submit');

Which calls the below:

public function submit(Request $request)
{
    $this->validate($request, [
        'first_name' => 'required|string',
        'last_name' => 'required|string',
        'email' => 'required|email'
    ]);

    $fields = [
        'first_name' => $request->input('first_name'),
        'last_name' => $request->input('last_name'),
        'email' => $request->input('email')
        'created_at' => time()
    ];

    $insert = DB::table('forms')->insert($fields);

    return response()->json([
        'success' => $insert,
        'fields' => $fields
    ],200);
}

If there's a validation error, it will 100% of the time return the expected json error information. HOWEVER, if the validator passes it will always insert into the database but then only 50% of the time actually return data and a response code. The rest of the time I get no response code, no response data. Using a Java based rest console, I get

  org.apache.http.NoHttpResponseException: our_server_ip:80 failed to respond

As a test I setup a GET route that returns a string, and that works 100% of the time as expected..

I really have no idea what could be causing such a random issue like this. There's nothing really unique about the setup of this, we're running Centos, HTTPD, mysql 5.7, php 5.6 and latest lumen. The only thing worth noting is this is living in a subdirectory of a Magento store, however I'm 'punching' through that with htaccess.

Really appreciate any insight here!

0 likes
0 replies

Please or to participate in this conversation.