Home
%3CLINGO-SUB%20id%3D%22lingo-sub-287708%22%20slang%3D%22en-US%22%3EAdditional%20Information%20about%20Silverlight%20Client%20Timeout%20Value%20when%20calling%20a%20WCF%20WebService%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287708%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Nov%2006%2C%202012%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EBy%20default%2C%20a%26nbsp%3BSilverlight%20client%20calling%20WCF%26nbsp%3Buses%20the%20timeout%20settings%20documented%20here%2C%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fsystem.servicemodel.channels.binding.sendtimeout%2528v%3Dvs.95%2529.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fsystem.servicemodel.channels.binding.sendtimeout%2528v%3Dvs.95%2529.aspx%20%3C%2FA%3E.%3C%2FP%3E%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3ESendTimeout%2C%20the%20default%20value%20is%201%20minute.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EReceiveTimeout%2C%20the%20default%20value%20is%2010%20minutes.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CP%3EIf%20you%20have%20more%20data%20to%20send%20to%20server%20or%20you%20are%20using%20Silverlight%20client%20over%20a%20slow%20connection%2C%201%20minute%20may%20not%20be%20enough.%20MSDN%20documents%20how%20you%20can%20use%20Silverlight%20ServicesReferences.ClientConfig%20binding%20setting%20to%20increase%20the%20client%20timeout%2C%20link%3A%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fcc197941(v%3Dvs.95).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fcc197941(v%3Dvs.95).aspx%20%3C%2FA%3E.%20But%26nbsp%3Bit%20may%20not%20always%20work%20as%20expected%20and%26nbsp%3Bit%20assumes%20Silverlight%26nbsp%3Bcustom%20timeout%20value%20is%20always%20shorter%20than%20IE%20browser%2FWinINet%20default%20timeout.%20If%20the%20Silverlight%20timeout%20is%20not%20shorter%20than%20IE%2FWinINet%20default%20timeout%2C%20changing%20ServicesReferences.ClientConfig%20setting%26nbsp%3Bwill%20not%20work.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFor%20example%2C%20here%20is%20my%20timeout%20setting%20in%20my%20ServicesReferences.ClientConfig%20file.%20Yes%2C%20I%20am%20using%26nbsp%3Ba%20very%20extremely%20large%20scenario%20to%20demo%20the%20story.%20%3CBR%20%2F%3E%20%3CCONFIGURATION%3E%3C%2FCONFIGURATION%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSYSTEM.SERVICEMODEL%3E%3C%2FSYSTEM.SERVICEMODEL%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CBINDINGS%3E%3C%2FBINDINGS%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CBASICHTTPBINDING%3E%3C%2FBASICHTTPBINDING%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CBINDINGNAME%3E%3CBR%20%2F%3E%3C%2FBINDINGNAME%3E%3C%2FP%3E%3CP%3EmaxReceivedMessageSize%3D%222147483647%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EcloseTimeout%3D%2200%3A59%3A00%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EopenTimeout%3D%2200%3A53%3A00%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EreceiveTimeout%3D%2203%3A15%3A00%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EsendTimeout%3D%2203%3A21%3A00%22%26gt%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSECURITYMODE%3E%3C%2FSECURITYMODE%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CCLIENT%3E%3C%2FCLIENT%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CENDPOINTADDRESS%3E%3CBR%20%2F%3E%3C%2FENDPOINTADDRESS%3E%3C%2FP%3E%3CP%3Ebinding%3D%22basicHttpBinding%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EbindingConfiguration%3D%22BasicHttpBinding_IService1%22%20%26nbsp%3Bcontract%3D%22ServiceReference1.IService1%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ename%3D%22BasicHttpBinding_IService1%22%20%2F%26gt%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1)%26nbsp%3BLet%20us%26nbsp%3Blook%20at%26nbsp%3BWebRequest.RegisterPrefix(%22http%3A%2F%2F%22%2C%20WebRequestCreator.BrowserHttp)%20case%2C%20which%20is%20by%20default.%26nbsp%3BAnd%20Silverlight%26nbsp%3Buses%20BrowserHttp%20stack.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20we%20look%20at%20the%20send%20event%2C%20here%20is%20timer%20in%20Silverlight%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E-%26gt%3B%200a7e2758%20System.Threading.TimerQueueTimer%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E-%26gt%3B%200a7e26a8%20System.Net.Browser.BrowserHttpWebRequest%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E-%26gt%3B%200a7e4cec%20MS.Internal.InternalWebRequest%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0%3A002%26gt%3B%20!do%200a7e2758%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EName%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.Threading.TimerQueueTimer%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMethodTable%3A%2079509288%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E794f72a8%26nbsp%3B%2040005a8%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2020%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.UInt32%26nbsp%3B%201%20instance%2012060000%20m_dueTime%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E794f72a8%26nbsp%3B%2040005a9%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2024%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.UInt32%26nbsp%3B%201%20instance%204294967295%20m_period%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E12060000%20milliseconds%20%3D%2012060%20seconds%20%3D%20201%20minutes%20%3D%20sendTimeout%3D%2203%3A21%3A00%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESo%2C%20the%20timeout%20value%20did%20get%20updated%20in%20IE%20browser%20from%20ServicesReferences.ClientConfig%2C%20but%20turns%20out%2C%20the%20change%20is%20only%20at%20System.Net.Browser.BrowserHttpWebRequest%20level%20to%20make%20timer%20trigger%20abort%20connection.%26nbsp%3BHowever%2C%20as%20I%20learnt%2C%20the%26nbsp%3Bunderlying%20WinINet%20connection%26nbsp%3Bstill%20continues%26nbsp%3Bto%20use%20the%20default%20WinINet%20timeout.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ENotice%20the%20callstack%20to%20show%20how%20Silverlight%20npctrl.dll%20is%20eventually%20calling%20into%20wininet.dll%20for%20HttpSendRequestExW%20to%20send%20out%20the%20request.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0%3A017%26gt%3B%20kL%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EChildEBP%20RetAddr%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eaad4%20750e31de%20WININET!HttpSendRequestExW%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eab18%20750c1734%20urlmon!CINetHttp%3A%3AINetAsyncSendRequest%2B0x3fd%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb33c%20750c1b92%20urlmon!CINetHttp%3A%3AINetAsyncOpenRequest%2B0x335%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb35c%20750c10e3%20urlmon!CINet%3A%3AINetAsyncConnect%2B0x27d%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb378%20750bd1b2%20urlmon!CINet%3A%3AINetAsyncOpen%2B0x15a%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb38c%20750bd168%20urlmon!CINet%3A%3AINetAsyncStart%2B0x1d%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb3a4%20750bd3c7%20urlmon!CINet%3A%3AStartCommon%2B0x1dd%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb3b8%20750b98da%20urlmon!CINet%3A%3AStartEx%2B0x1a%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb3ec%20750b8d2b%20urlmon!COInetProt%3A%3AStartEx%2B0xc1%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb450%20750ba097%20urlmon!CTransaction%3A%3AStartEx%2B0x40b%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb4ec%20750a386c%20urlmon!CBinding%3A%3AStartBinding%2B0x883%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eb558%205cfb3ace%20urlmon!operator%20new%2B0x20%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ec664%205cfb40ca%20npctrl!CWindowsDownloadRequest%3A%3A_Download%2B0x446%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed8d0%205cfb431d%20npctrl!CWindowsDownloadRequest%3A%3AInitiateRequest%2B0x5ea%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed938%205cfb3835%20npctrl!CXcpBrowserHost%3A%3AProcessAsyncDownloadRequest_BrowserImpl%2B0x2a7%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed980%205cfb36ef%20npctrl!CXcpBrowserHost%3A%3AProcessAsyncDownloadRequest%2B0x117%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed9c0%205cfb3526%20npctrl!CDownloadRequest%3A%3ADownload%2B0x4f%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed9e0%205cfb34cd%20npctrl!CAsyncDownloadRequestManager%3A%3ADownloadRequests%2B0x48%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056ed9f4%205cfa48a4%20npctrl!CXcpDispatcher%3A%3AOnWindowMessage%2B0x114%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E056eda0c%205cfa3270%20npctrl!CXcpDispatcher%3A%3AProcessMessage%2B0xa2%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20you%20continue%20debugging%20into%20the%20HttpSendRequestExW%20first%20parameter%20of%26nbsp%3B%20hRequest%20%3D%200x00cc000c%26nbsp%3Bhandle%20with%20debugging%20symbol%2C%20you%20will%20see%20the%20IE%2FWinINet%20timeout%2C%20such%20as%20SendTimeOut%20and%20ReceiveTimeOut%2C%26nbsp%3Bis%20still%26nbsp%3Busing%20the%20default%20IE%20timeout%20value.%20It%20is%20not%20modified%26nbsp%3Bby%20your%20ServicesReferences.ClientConfig%20setting%20of%20timeout.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2)%20Now%2C%20let%20us%20look%20at%20ClientHttp%20case%2C%26nbsp%3Bi.e.%20WebRequest.RegisterPrefix(%22http%3A%2F%2F%22%2C%20WebRequestCreator.ClientHttp)%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ENote%3A%20For%20the%20difference%20between%20ClientHttp%20vs%20BrowserHttp%20handling%20in%20Silverlight%2C%20please%20check%20MSDN%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fdd920295%2528v%3DVS.95%2529.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fdd920295%2528v%3DVS.95%2529.aspx%20%3C%2FA%3E.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ENow%20it%20is%20Silverlight%20npctrl.dll%20%2F%26nbsp%3Bnpctrl!CWindowsOSWebRequest%20class%20still%20calling%20WinINet.%20The%20difference%20is%3A%20It%20is%20calling%20Wininet.dll%20directly%20instead%20of%20UrlMon%20build-in%20BrowserHttp%20stack.%20So%2C%20ClientHttp%20implementation%20is%20still%20on%20top%20of%20wininet.dll%20for%20underlying%20connection%20instead%20of%20winsock%20in%20order%20to%20avoid%20ClientHttp%20implementing%20the%20protocol%20details.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ECallstack%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0%3A044%26gt%3B%20kL%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EChildEBP%20RetAddr%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5f954%205cfb933e%20WININET!HttpSendRequestW%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5fac0%205cfb8b71%20npctrl!CWindowsOSWebRequest%3A%3ADoOperatingSystemWebRequest%2B0xbd4%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5faf0%205e29027b%20npctrl!COperatingSystemWebRequest%3A%3AOperatingSystemWebRequestThreadFn%2B0x60%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5fb08%207689339a%20IEFRAME!_Detour_ThreadProc%2B0x23%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5fb14%2077319ef2%20kernel32!BaseThreadInitThunk%2B0xe%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5fb54%2077319ec5%20ntdll!__RtlUserThreadStart%2B0x70%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0ea5fb6c%2000000000%20ntdll!_RtlUserThreadStart%2B0x1b%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20you%20debug%20into%20the%20WININET!HttpSendRequestW%20handle%20level%2C%20you%20will%20see%20the%20WinINet%20is%20still%20using%20IE%20default%20SendTimeout%20value%20instead%20of%20your%20ServicesReferences.ClientConfig%20timeout%20value.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBut%2C%20again%2C%20.NET%20level%20timer%20is%203%3A21%20hours%2C%20which%20is%20much%20longer%20than%20WinINet%20layer%20can%20possibly%20even%20keep%20the%20connection.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E0%3A044%26gt%3B%20!do%200acf6594%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EName%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.Threading.TimerQueueTimer%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMethodTable%3A%2079509288%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EEEClass%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20790b83e0%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESize%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2052(0x34)%20bytes%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFile%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20C%3A%5CProgram%20Files%20(x86)%5CMicrosoft%20Silverlight%5C5.1.10411.0%5Cmscorlib.dll%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFields%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMT%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Field%26nbsp%3B%26nbsp%3B%20Offset%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Type%20VT%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Attr%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Value%20Name%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E79509288%26nbsp%3B%2040005a5%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%204%20...g.TimerQueueTimer%26nbsp%3B%200%20instance%2000000000%20m_next%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E79509288%26nbsp%3B%2040005a6%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%208%20...g.TimerQueueTimer%26nbsp%3B%200%20instance%2000000000%20m_prev%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E794f71d4%26nbsp%3B%2040005a7%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%201c%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.Int32%26nbsp%3B%201%20instance%20495612727%20m_startTicks%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E794f72a8%26nbsp%3B%2040005a8%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2020%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20System.UInt32%26nbsp%3B%201%20instance%2012060000%20m_dueTime%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E12060000%20milliseconds%20%3D%2012060%20seconds%20%3D%20201%20minutes%20%3D%20sendTimeout%3D%2203%3A21%3A00%22%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESo%2C%20you%20can%20see%20Silverlight%20creates%20WinINet%20connection%20as%20the%20underlying%20connection%20implementation.%20But%20when%20you%20create%20your%20own%20wcf%20Silverlight%20client%20timeout%20values%20in%20ServicesReferences.ClientConfig%2C%20a%20timer%20is%20created%20at%20.NET%20layer%2C%20but%20doesn't%20modify%20the%20underlying%20WinINet%20timeout%20values%2C%20which%20includes%20both%20SendTimeOut%20and%20RecieveTimeOut%20for%20WinINet.%20It%20will%20work%20only%20if%20your%20timeout%20setting%20in%20ServicesReferences.ClientConfig%26nbsp%3Bis%20less%20than%20or%20equal%20to%20IE%2FWinINet%20timeout%20setting.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESo%2C%20how%20can%20we%20also%20update%20the%20SendTimeOut%20and%20ReceiveTimeout%20at%20IE%20WinINet%20level%20for%20my%20Silverlight%20client%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAnswer%3A%20We%20can%20only%20do%20it%20through%20IE%20regkey%20(applies%20to%20IE%20browser%20only).%20Here%20is%20the%20location%20and%20key%20name%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%5BHKCU%5CSoftware%5CMicrosoft%5Cwindows%5Ccurrentversion%5Cinternet%20settings%5C%5D%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EReceiveTimeout%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EDWORD%20in%20Millisecond%20unit%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESendTimeout%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EDWORD%20in%20Millisecond%20unit%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%0A%20%0A%3CLINGO-TEASER%20id%3D%22lingo-teaser-287708%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Nov%2006%2C%202012%20By%20default%2C%20a%26nbsp%3BSilverlight%20client%20calling%20WCF%26nbsp%3Buses%20the%20timeout%20settings%20documented%20here%2C%20http%3A%2F%2Fmsdn.%3C%2FLINGO-TEASER%3E
Microsoft
First published on MSDN on Nov 06, 2012

By default, a Silverlight client calling WCF uses the timeout settings documented here, http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.sendtimeout%28v=vs... .



  • SendTimeout, the default value is 1 minute.

  • ReceiveTimeout, the default value is 10 minutes.


If you have more data to send to server or you are using Silverlight client over a slow connection, 1 minute may not be enough. MSDN documents how you can use Silverlight ServicesReferences.ClientConfig binding setting to increase the client timeout, link: http://msdn.microsoft.com/en-us/library/cc197941(v=vs.95).aspx . But it may not always work as expected and it assumes Silverlight custom timeout value is always shorter than IE browser/WinINet default timeout. If the Silverlight timeout is not shorter than IE/WinINet default timeout, changing ServicesReferences.ClientConfig setting will not work.


For example, here is my timeout setting in my ServicesReferences.ClientConfig file. Yes, I am using a very extremely large scenario to demo the story.
<configuration>


<system.serviceModel>


<bindings>


<basicHttpBinding>


<bindingname="BasicHttpBinding_IService1"maxBufferSize="2147483647"


maxReceivedMessageSize="2147483647"


closeTimeout="00:59:00"


openTimeout="00:53:00"


receiveTimeout="03:15:00"


sendTimeout="03:21:00">


<securitymode="None" />


</binding>


</basicHttpBinding>


</bindings>


<client>


<endpointaddress="http://hzmain/WCFtest/Service1.svc"


binding="basicHttpBinding"


bindingConfiguration="BasicHttpBinding_IService1"  contract="ServiceReference1.IService1"


name="BasicHttpBinding_IService1" />


</client>


</system.serviceModel>


</configuration>


1) Let us look at WebRequest.RegisterPrefix("http://", WebRequestCreator.BrowserHttp) case, which is by default. And Silverlight uses BrowserHttp stack.


If we look at the send event, here is timer in Silverlight:


-> 0a7e2758 System.Threading.TimerQueueTimer


-> 0a7e26a8 System.Net.Browser.BrowserHttpWebRequest


-> 0a7e4cec MS.Internal.InternalWebRequest



0:002> !do 0a7e2758


Name:        System.Threading.TimerQueueTimer


MethodTable: 79509288


794f72a8  40005a8       20        System.UInt32  1 instance 12060000 m_dueTime


794f72a8  40005a9       24        System.UInt32  1 instance 4294967295 m_period


12060000 milliseconds = 12060 seconds = 201 minutes = sendTimeout="03:21:00"


So, the timeout value did get updated in IE browser from ServicesReferences.ClientConfig, but turns out, the change is only at System.Net.Browser.BrowserHttpWebRequest level to make timer trigger abort connection. However, as I learnt, the underlying WinINet connection still continues to use the default WinINet timeout.



Notice the callstack to show how Silverlight npctrl.dll is eventually calling into wininet.dll for HttpSendRequestExW to send out the request.


0:017> kL


ChildEBP RetAddr


056eaad4 750e31de WININET!HttpSendRequestExW


056eab18 750c1734 urlmon!CINetHttp::INetAsyncSendRequest+0x3fd


056eb33c 750c1b92 urlmon!CINetHttp::INetAsyncOpenRequest+0x335


056eb35c 750c10e3 urlmon!CINet::INetAsyncConnect+0x27d


056eb378 750bd1b2 urlmon!CINet::INetAsyncOpen+0x15a


056eb38c 750bd168 urlmon!CINet::INetAsyncStart+0x1d


056eb3a4 750bd3c7 urlmon!CINet::StartCommon+0x1dd


056eb3b8 750b98da urlmon!CINet::StartEx+0x1a


056eb3ec 750b8d2b urlmon!COInetProt::StartEx+0xc1


056eb450 750ba097 urlmon!CTransaction::StartEx+0x40b


056eb4ec 750a386c urlmon!CBinding::StartBinding+0x883


056eb558 5cfb3ace urlmon!operator new+0x20


056ec664 5cfb40ca npctrl!CWindowsDownloadRequest::_Download+0x446


056ed8d0 5cfb431d npctrl!CWindowsDownloadRequest::InitiateRequest+0x5ea


056ed938 5cfb3835 npctrl!CXcpBrowserHost::ProcessAsyncDownloadRequest_BrowserImpl+0x2a7


056ed980 5cfb36ef npctrl!CXcpBrowserHost::ProcessAsyncDownloadRequest+0x117


056ed9c0 5cfb3526 npctrl!CDownloadRequest::Download+0x4f


056ed9e0 5cfb34cd npctrl!CAsyncDownloadRequestManager::DownloadRequests+0x48


056ed9f4 5cfa48a4 npctrl!CXcpDispatcher::OnWindowMessage+0x114


056eda0c 5cfa3270 npctrl!CXcpDispatcher::ProcessMessage+0xa2



If you continue debugging into the HttpSendRequestExW first parameter of  hRequest = 0x00cc000c handle with debugging symbol, you will see the IE/WinINet timeout, such as SendTimeOut and ReceiveTimeOut, is still using the default IE timeout value. It is not modified by your ServicesReferences.ClientConfig setting of timeout.



2) Now, let us look at ClientHttp case, i.e. WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp):


Note: For the difference between ClientHttp vs BrowserHttp handling in Silverlight, please check MSDN http://msdn.microsoft.com/en-us/library/dd920295%28v=VS.95%29.aspx .


Now it is Silverlight npctrl.dll / npctrl!CWindowsOSWebRequest class still calling WinINet. The difference is: It is calling Wininet.dll directly instead of UrlMon build-in BrowserHttp stack. So, ClientHttp implementation is still on top of wininet.dll for underlying connection instead of winsock in order to avoid ClientHttp implementing the protocol details.


Callstack:


0:044> kL


ChildEBP RetAddr


0ea5f954 5cfb933e WININET!HttpSendRequestW


0ea5fac0 5cfb8b71 npctrl!CWindowsOSWebRequest::DoOperatingSystemWebRequest+0xbd4


0ea5faf0 5e29027b npctrl!COperatingSystemWebRequest::OperatingSystemWebRequestThreadFn+0x60


0ea5fb08 7689339a IEFRAME!_Detour_ThreadProc+0x23


0ea5fb14 77319ef2 kernel32!BaseThreadInitThunk+0xe


0ea5fb54 77319ec5 ntdll!__RtlUserThreadStart+0x70


0ea5fb6c 00000000 ntdll!_RtlUserThreadStart+0x1b


If you debug into the WININET!HttpSendRequestW handle level, you will see the WinINet is still using IE default SendTimeout value instead of your ServicesReferences.ClientConfig timeout value.


But, again, .NET level timer is 3:21 hours, which is much longer than WinINet layer can possibly even keep the connection.


0:044> !do 0acf6594


Name:        System.Threading.TimerQueueTimer


MethodTable: 79509288


EEClass:     790b83e0


Size:        52(0x34) bytes


File:        C:\Program Files (x86)\Microsoft Silverlight\5.1.10411.0\mscorlib.dll


Fields:


MT    Field   Offset                 Type VT     Attr    Value Name


79509288  40005a5        4 ...g.TimerQueueTimer  0 instance 00000000 m_next


79509288  40005a6        8 ...g.TimerQueueTimer  0 instance 00000000 m_prev


794f71d4  40005a7       1c         System.Int32  1 instance 495612727 m_startTicks


794f72a8  40005a8       20        System.UInt32  1 instance 12060000 m_dueTime


12060000 milliseconds = 12060 seconds = 201 minutes = sendTimeout="03:21:00"


So, you can see Silverlight creates WinINet connection as the underlying connection implementation. But when you create your own wcf Silverlight client timeout values in ServicesReferences.ClientConfig, a timer is created at .NET layer, but doesn't modify the underlying WinINet timeout values, which includes both SendTimeOut and RecieveTimeOut for WinINet. It will work only if your timeout setting in ServicesReferences.ClientConfig is less than or equal to IE/WinINet timeout setting.


So, how can we also update the SendTimeOut and ReceiveTimeout at IE WinINet level for my Silverlight client?


Answer: We can only do it through IE regkey (applies to IE browser only). Here is the location and key name:


[HKCU\Software\Microsoft\windows\currentversion\internet settings\]


ReceiveTimeout


DWORD in Millisecond unit


SendTimeout


DWORD in Millisecond unit