function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sumant KuchipudiSumant Kuchipudi 

Getting SalesforceException: Remotely closed

Hi,
I'm using Mulesoft integration tool and invoking Salesforce Apex Rest API (@RestResource(urlMapping = '/matchingtool/*'), it is working since year until couple of weeks or less. for each hour in a 24 hour window the integration may invoke this api for 1000 times, most of the hours it is working completely for those 1000 but for couple of hourls it's failing with this exception. I poste d question in Mulesoft but everyone replying that this might be Salesforce issue so checking here.
Below is Apex code:
@RestResource(urlMapping = '/matchingtool/*')
global class EmpMatchingTool {
    @HttpPost
    global static String getIdByIdentifiers(Identifiers identifiers) {
        ---------
   }
}

Below is complete exception:
org.mule.extension.salesforce.internal.error.exception.service.SalesforceException: Remotely closed
	at org.mule.extension.salesforce.internal.error.exception.service.handlers.IOExceptionHandler.handle(IOExceptionHandler.java:44)
	at org.mule.extension.salesforce.internal.connection.ForceWSCConnection.send(ForceWSCConnection.java:332)
	at org.mule.extension.salesforce.internal.service.apex.rest.ApexRestInvocation.invokeApexRest(ApexRestInvocation.java:392)
	at org.mule.extension.salesforce.internal.service.apex.util.ApexClient.invokeRestMethod(ApexClient.java:188)
	at org.mule.extension.salesforce.internal.service.ApexServiceImpl.lambda$invokeRestMethod$1(ApexServiceImpl.java:66)
	at org.mule.extension.salesforce.internal.connection.ForceWSCConnection.executeOverApexRestClient(ForceWSCConnection.java:239)
	at org.mule.extension.salesforce.internal.service.ForceWSCService.executeOverApexRestClient(ForceWSCService.java:28)
	at org.mule.extension.salesforce.internal.service.ApexServiceImpl.invokeRestMethod(ApexServiceImpl.java:53)
	at org.mule.extension.salesforce.internal.operation.apex.InvokeApexRestMethodOperation.invokeApexRestMethod(InvokeApexRestMethodOperation.java:54)
	at org.mule.extension.salesforce.internal.operation.apex.InvokeApexRestMethodOperation$invokeApexRestMethod$MethodComponentExecutor.execute(Unknown Source)
	at org.mule.runtime.module.extension.internal.runtime.execution.GeneratedMethodComponentExecutor.execute(GeneratedMethodComponentExecutor.java:97)
	at org.mule.runtime.module.extension.internal.runtime.execution.CompletableMethodOperationExecutor.doExecute(CompletableMethodOperationExecutor.java:29)
	at org.mule.runtime.module.extension.internal.runtime.execution.AbstractCompletableMethodOperationExecutor.execute(AbstractCompletableMethodOperationExecutor.java:63)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeCommand(DefaultExecutionMediator.java:211)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$executeWithInterceptors$6(DefaultExecutionMediator.java:192)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$executeWithRetry$2(DefaultExecutionMediator.java:130)
	at net.jodah.failsafe.Functions.lambda$promiseOfStage$8(Functions.java:193)
	at net.jodah.failsafe.internal.executor.RetryPolicyExecutor$1.call(RetryPolicyExecutor.java:101)
	at net.jodah.failsafe.internal.executor.RetryPolicyExecutor.lambda$supplyAsync$1(RetryPolicyExecutor.java:133)
	at net.jodah.failsafe.Functions.lambda$null$1(Functions.java:69)
	at org.mule.runtime.core.internal.util.rx.ConditionalExecutorServiceDecorator.synchronousSchedule(ConditionalExecutorServiceDecorator.java:181)
	at org.mule.runtime.core.internal.util.rx.ConditionalExecutorServiceDecorator.schedule(ConditionalExecutorServiceDecorator.java:167)
	at net.jodah.failsafe.Functions.lambda$makeAsync$2(Functions.java:79)
	at net.jodah.failsafe.AsyncExecution.executeAsync(AsyncExecution.java:174)
	at net.jodah.failsafe.FailsafeExecutor.callAsync(FailsafeExecutor.java:346)
	at net.jodah.failsafe.FailsafeExecutor.getStageAsync(FailsafeExecutor.java:178)
	at org.mule.runtime.core.internal.retry.policies.SimpleRetryPolicy.applyPolicy(SimpleRetryPolicy.java:90)
	at org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate.applyPolicy(RetryPolicyTemplate.java:144)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeWithRetry(DefaultExecutionMediator.java:128)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeWithInterceptors(DefaultExecutionMediator.java:192)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$execute$1(DefaultExecutionMediator.java:113)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$new$0(DefaultExecutionMediator.java:61)
	at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.execute(DefaultExecutionMediator.java:112)
	at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.executeOperation(ComponentMessageProcessor.java:563)
	at org.mule.runtime.module.extension.internal.runtime.operation.OAuthOperationMessageProcessor.executeOperation(OAuthOperationMessageProcessor.java:58)
	at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.prepareAndExecuteOperation(ComponentMessageProcessor.java:765)
	at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.access$100(ComponentMessageProcessor.java:185)
	at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor$4.lambda$innerEventDispatcher$9(ComponentMessageProcessor.java:637)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.tryOnNext(FluxPeekFuseable.java:510)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.tryOnNext(FluxPeekFuseable.java:523)
	at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.runAsync(FluxPublishOn.java:866)
	at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.run(FluxPublishOn.java:939)
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
	at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

 
AnudeepAnudeep (Salesforce Developers) 
This is documented here. I suggest following the workaround 

When sending the HTTP POST request using the HTTP requester, sometimes you may encounter the exception of "Remotely Closed", this is usually encountered for HTTP POST request only
 
Sumant KuchipudiSumant Kuchipudi
Thanks Anudeep for your reply.
The problem raised in Salesforce connector not from Mulesoft HTTP POST requester and there is no POST request in the flow. This issue is in salesforce side.
Permender Singh 8Permender Singh 8
Hello Sumant,
I am facing the same issue. Were you able to find any solution for it?