WSO2 MI, integration timeouts while trying to reach backend

Viewed 194

i'm trying to build my integration with Integration Studio, it has to pass through multiple services and send the response to a backend endpoint. This works very well until it tries to call backend, then it goes on timeout state.

Here the XML

<?xml version="1.0" encoding="UTF-8"?>
<api context="/salesforce" name="SFApi" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" uri-template="/anagrafiche">
        <inSequence>
            <property expression="$body//username" name="uri.var.username" scope="default" type="STRING"/>
            <property expression="$body//password" name="uri.var.password" scope="default" type="STRING"/>
            <property expression="$body//client_id" name="uri.var.client_id" scope="default" type="STRING"/>
            <property expression="$body//client_secret" name="uri.var.client_secret" scope="default" type="STRING"/>
            <property expression="$body//grant_type" name="uri.var.grant_type" scope="default" type="STRING"/>
            <call>
                <endpoint key="SFAuth"/>
                <source type="body"/>
            </call>
            <property expression="json-eval($.access_token)" name="uri.var.accessToken" scope="default" type="STRING"/>
            <header expression="fn:concat('Bearer ', $ctx:uri.var.accessToken)" name="Authorization" scope="transport"/>
            <call>
                <endpoint key="SFAnagrafiche"/>
            </call>
            <property expression="json-eval($.records)" name="uri.var.records" scope="default" type="STRING"/>
            <call>
                <endpoint key="BEAnagrafiche"/>
                <source type="body"/>
                <target type="body"/>
            </call>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

The schema goes on until it calls BEAnagrafiche's endpoint, which has the following http REST url to a laravel project in POST method:

http://localhost/webidoo-project/public/api/anagrafiche

Here BEAnagrafiche's XML:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="BEAnagrafiche" xmlns="http://ws.apache.org/ns/synapse">
    <http method="post" uri-template="http://localhost/webidoo-project/public/api/anagrafiche">
        <suspendOnFailure>
            <initialDuration>-1</initialDuration>
            <progressionFactor>1.0</progressionFactor>
        </suspendOnFailure>
        <markForSuspension>
            <retriesBeforeSuspension>0</retriesBeforeSuspension>
        </markForSuspension>
    </http>
    <property name="data" value="$ctx:uri.var.records"/>
</endpoint>

And the backend service:

public function saveAnagrafiche(Request $request) {
       return 'hello';
        try {
            DB::beginTransaction();

            $data = $request->json();

            foreach($data as $d) {
                if(isset($d['attributes'])) unset($d['attributes']);
                $user = new User($d);
                $user->save();
            }

            DB::commit();
            return response()->json([
                'status' => true,
                'message' => 'Anagrafiche salvate correttamente'
            ], 200);
        } catch(\Exception $e) {
            DB::rollback();
            return response()->json([
                'status' => false,
                'message' => 'Errore durante il salvataggio delle anagrafiche',
                'error' => $e->getMessage()
            ], 500);
        }
    }

Here below also last messages from mi's console:

enter image description here

passthru-http.properties:

#
# Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
##############################################
#
# WARNING: Don't edit the file manually unless you are not using the deployment.toml file.
#
##############################################

## This file contains the configuration parameters used by the Pass-through HTTP transport

rest.dispatcher.service=__MultitenantDispatcherService
rest_uri_api_regex=\\w+://.+:\\d+/t/.*|\\w+://.+\\w+/t/.*|^(/t/).*
rest_uri_proxy_regex=\\w+://.+:\\d+/services/t/.*|\\w+://.+\\w+/services/t/.*|^(/services/t/).*
http.socket.reuseaddr=true

http.user.agent.preserve = false
worker_pool_size_max = 400
valid.max.message.size.in.bytes = 81920
worker_pool_size_core = 400
http.max.connection.per.host.port = 32767
io_buffer_size = 16384
http.server.preserve = true
http.connection.disable.keepalive = false
http.socket.timeout=600000
force.json.message.reverseProxyMode = false
worker_pool_queue_length = -1

http.headers.preserve=Content-Type

synapse.properties:

#
# Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

##############################################
#
# WARNING: Don't edit the file manually unless you are not using the deployment.toml file.
#
##############################################

opentracing.enable = false
inbound.threads.core = 20
synapse.debugger.port.command = 9005
synapse.debugger.port.event = 9006
internal.https.api.port = 9154
synapse.xpath.func.extensions = org.wso2.micro.integrator.mediation.security.vault.xpath.SecureVaultLookupXPathFunctionProvider,org.wso2.micro.integrator.mediation.security.vault.external.hashicorp.HashiCorpVaultLookupXPathFunctionProvider
jaeger.sender.agent.host = localhost
synapse.commons.json.preserve.namespace = false
jaeger.reporter.log.spans = false
internal.http.api.enabled = true
inbound.port.offset.enable = false
synapse.temp_data.chunk.size = 3072
mediation.flow.statistics.enable = false
mediation.flow.statistics.collect.all = false
internal.http.api.port = 9191
synapse.threads.core = 20
opentracing.zipkin.backend.url = http://localhost:9411/api/v2/spans
jaeger.reporter.flush.interval = 10000
inbound.threads.max = 100
synapse.global_timeout_interval = 120000
jaeger.sampler.manager.host = localhost
opentracing.zipkin.enable = false
synapse.script.mediator.pool.size = 15
jaeger.reporter.max.queue.size = 100
mediation.flow.statistics.tracer.collect.properties = false
synapse.threads.max = 100
jaeger.sender.agent.port = 6831
statistics.clean.enable = true
mediation.flow.statistics.tracer.collect.payloads = false
statistics.clean.interval = 1000
jaeger.sampler.manager.port = 5778
synapse.sal.endpoints.sesssion.timeout.default=600000
synapse.carbon.ext.tenant.info=org.wso2.micro.integrator.initializer.handler.MITenantInfoConfigurator
mediation.flow.statistics.event.consume.interval=1000
mediation.flow.statistics.event.clean.interval=15000

1 Answers

According to the shared screenshot of the error message, it seems a socket timeout has occurred between the client and the server. The timeout has occurred only after the server has accepted request headers and body.

  1. Have you tried invoking the backend service directly?
  2. If it is working properly, how much time it takes to respond?
  3. Have you observed any latency at your client-side?
  4. Enable the wire logs as in this doc and share it.
Related