I am using a SharePoint 2013 based server on which I deployed a simple WCF service as a farm solution. The service accepts simple Http mail requests that contain individual MS Word documents as a payload and returns these files converted to PDF files. The service is available through Http for anonymous users. WordAutomationService acts as the SharePoint server administrator account.
The service class creates a new instance of Microsoft.Office.Word.Server.Conversions.SyncConverter and passes the SharePoint proxy running WordAutomationService to the constructor (along with some ConversionJobSettings). Finally, he calls the Convert method on SyncConverter with an input stream (Word document) and an output stream (web response that will contain the resulting PDF document created by WordAutomationService).
When creating a SyncConverter, I do not set the UserToken property because the service is accessed by anonymous users. As noted here https://msdn.microsoft.com/en-us/library/microsoft.office.word.server.conversions.syncconverter.usertoken.aspx this looks ok:
The default value for this property is a null reference (Nothing in Visual Basic), which is anonymous.
This setting is great for small Word documents with multiple pages and returns the expected PDF files. But as soon as the execution time of the WordAutomationService in SharePoint exceeds a certain time threshold (about 5 seconds), the service fails because it never returns (which leads to a read timeout on the client). According to the logs, it seems that the reason is that after a while the synchronous conversion task moves the work to the background process:
Stream job conversion synchronization takes too much time. Don't wait anymore. Check his status later
He then regularly checks the status of this job by calling ConversionServiceApplicationProxy.BatchGetSyncJobStatus. Unfortunately, this call fails because it is trying to create a new channel to discuss this process, and this requires a security token. However, SecurityTokenService cannot fulfill the request for the token and throws an exception:
An unhandled exception has occurred. The security token request cannot be completed. System.InvalidOperationException: The security token request cannot be completed. at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForServiceContext(Uri contextUri) at Microsoft.SharePoint.SPChannelFactoryOperations.InternalCreateChannelActingAsLoggedOnUser[TChannel](ChannelFactory`1 factory, EndpointAddress address, Uri via) at Microsoft.Office.ConversionServices.Service.ConfigChannelFactory`1.CreateChannel(EndpointAddress address) at Microsoft.Office.ConversionServices.Service.ConversionServiceApplicationProxy.GetChannel(Uri uri) at Microsoft.Office.ConversionServices.Service.ConversionServiceApplicationProxy.ExecuteOnChannel(Uri endpointAddress, Action`1 action) at Microsoft.Office.ConversionServices.Service.ConversionServiceApplicationProxy.BatchGetSyncJobStatus(ICollection`1 ucids, Uri endpointAddress) at Microsoft.Office.ConversionServices.Service.BatchGetStatusPollingThread.Run() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() StackTrace: at onetnative.dll: (sig=37460b31-4453-4365-92f5-3a11c267be48|2|onetnative.pdb, offset=28F56) at onetnative.dll: (offset=15735)
Now Iβm at a loss how to get rid of the marker problem so that the system can create the necessary channel for polling the status of the conversion job. Any help is much appreciated. Thanks!
(I can not publish the full journal because it is registered as spam)