我在服务器和客户端之间的通信中使用WCF(都是用C#编写的).
在释放模式下,时间应设置为~20秒,但在调试模式下,我想将它们设置为更高的值,以便我可以调试/插入代码而不会发生超时.
我知道我可以通过修改app.config文件来更改超时.但是,我有两个不同的绑定和4个超时值,所以我不得不在几个地方改变,它很容易忘记.
为了解决这个问题,我想在我的代码中有一个小的#if DEBUG-section,它以编程方式将超时值更改为1小时.
我尝试使用以下代码执行此操作:
Configuration configuration =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ServiceModelSectionGroup serviceModel =
ServiceModelSectionGroup.GetSectionGroup(configuration);
BindingsSection bindings = serviceModel.Bindings;
foreach (var configuredBinding in bindings.WSHttpBinding.ConfiguredBindings)
{
configuredBinding.CloseTimeout = new TimeSpan(0, 30, 0);
configuredBinding.OpenTimeout = new TimeSpan(0, 30, 0);
Run Code Online (Sandbox Code Playgroud)
但*Timeout属性是readonly所以我得到编译错误.
我不喜欢以编程方式从头开始创建绑定的想法.如果我更改了app.config中的一些属性,我必须记住在代码中进行相同的更改,以确保调试行为类似于发布行为(超时除外).
怎么办呢?
哦,天哪,今天很多 - 哎呀
伙计们,最好的办法:
$j('.done').append('Your services have been updated');
Run Code Online (Sandbox Code Playgroud)
(那些位完成)
但是在说5秒之后删除附加,这样如果一个人重新提交表格(允许),附加不会继续添加文字?即更新一次"您的服务已更新",两次会显示"您的服务已更新您的服务已更新"但我只希望您的服务已更新以显示一次
我必须为给定的WSDL文件实现webservice客户端.我使用SDK的'wsimport'工具从WSDL创建Java类,以及将webservice唯一的方法(enhanceAddress(auth, param, address))包装到一个简单的java方法中的类.到现在为止还挺好.Web服务功能正常,返回结果正确.代码如下所示:
try {
EnhancedAddressList uniservResponse = getWebservicePort().enhanceAddress(m_auth, m_param, uniservAddress);
//Where the Port^ is the HTTP Soap 1.2 Endpoint
}catch (Throwable e) {
throw new AddressValidationException("Error during uniserv webservice request.", e);
}
Run Code Online (Sandbox Code Playgroud)
问题现在:我需要获取有关连接的信息以及为了填充各种JMX值而可能发生的任何错误(例如COUNT_READ_TIMEOUT,COUNT_CONNECT_TIMEOUT,...)不幸的是,该方法没有正式抛出任何异常,所以按顺序获取有关的ConnectException细节,我需要使用getCause()的ClientTransportException,将被抛出.
更糟糕的是:我试图测试读取超时值,但没有.我在wsdl文件中更改了服务的位置,将请求发布到php脚本,该脚本只是永远等待而不会返回.你猜怎么着:Web服务客户端并没有超时,但将永远等待,以及(我30多分钟的等待后,杀死了应用程序).这不是我的应用程序的一个选项,因为如果其中一些被"卡住",我最终会用完tcp连接.
该enhanceAddress(auth, param, address)方法未实现,但使用javax.jws注释.*注释,意味着我无法查看/更改/检查实际执行的代码.
我有什么选择,但要扔掉整个wsimport/javax.jsw-stuff并实现我自己的soap客户端?
昨天AWS的RDS下降了 - 我们的数据库也是如此.
发生这种情况时,C3P0会尝试获取数据库连接并挂起.我显然希望我的应用程序在这些实例中返回错误页面,而不是仅仅等待响应.
这是代码的样子:
ComboPooledDataSource db = new ComboPooledDataSource();
...
Connection conn = db.getConnection();
Run Code Online (Sandbox Code Playgroud)
如何设置从c3p0的连接池获取连接的超时?
我以为checkoutTimeout()就是它 - 但事实并非如此.它是"当池耗尽时,客户端调用getConnection()将等待连接被签入或获取的毫秒数." 由于池没有用尽(它只是不可用),这不适用.
我还认为setAcquireRetryAttempts和setAcquireIncrement可以工作 - 但是它们不会因为连接没有失败,所以它只是没有响应.
当我拉动整个堆栈时,这就是它停止的地方:
SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
SocketInputStream.read(byte[], int, int) line: 129
ReadAheadInputStream.fill(int) line: 113
ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(byte[], int, int) line: 160
ReadAheadInputStream.read(byte[], int, int) line: 188
MysqlIO.readFully(InputStream, byte[], int, int) line: 2428
MysqlIO.reuseAndReadPacket(Buffer, int) line: 2882
MysqlIO.reuseAndReadPacket(Buffer) line: 2871
MysqlIO.checkErrorPacket(int) line: 3414
MysqlIO.sendCommand(int, String, Buffer, boolean, String) line: 1936
MysqlIO.sqlQueryDirect(StatementImpl, String, String, Buffer, int, …Run Code Online (Sandbox Code Playgroud) 我正在使用对象MSXML2.ServerXMLHTTP60向webservice发送请求; 有了这个对象,我可以通过异步方法加速数据加载,并避免锁定Excel屏幕(没有响应).但是,我仍然有一个问题,当webservice响应很长一段时间,出于ServerXMLHTTP60超时设置,请求函数是默默的,我无法捕获超时错误.在另一个问题上,@ osknows建议使用xmlhttp status = 408捕捉超时错误,但它对我不起作用.
我已经准备好了一个测试文件,你可以在这里下载.按下打开VBA源代码Atl + F8,您将看到CXMLHTTPHandler我从本指南中复制的类模块
If m_xmlHttp.readyState = 4 Then
If m_xmlHttp.Status = 200 Then
MsgBox m_xmlHttp.responseText
ElseIf m_xmlHttp.Status = 408 Then 'Debug never run to here?
MsgBox "Request timeout"
Else
'Error happened
End If
End If
Run Code Online (Sandbox Code Playgroud)
如何VBA捕获请求超时错误?
谢谢您帮忙!
作为持续集成构建过程的一部分运行的WatiN步骤在尝试间歇性地附加到浏览器实例时失败.目前约有五分之一.
Browser.AttachTo<IE>(Find.ByTitle("Title of Popup"));
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.ThrowTimeOutException(Exception lastException, String message)
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.HandleTimeOut()
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try[T](DoFunc`1 func)
at WatiN.Core.WaitForCompleteBase.WaitUntil(DoFunc`1 waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitUntilNotNull(DoFunc`1 func, BuildTimeOutExceptionMessage exceptionMessage)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitWhileIEBusy(IWebBrowser2 ie)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout()
at WatiN.Core.WaitForCompleteBase.DoWait()
at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.FinishInitializationAndWaitForComplete(IE ie, SimpleTimer timer, Boolean waitForComplete)
at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.Find(Constraint findBy, Int32 timeout, Boolean waitForComplete)
at WatiN.Core.Browser.AttachTo[T](Constraint constraint)
Run Code Online (Sandbox Code Playgroud)
我已经完成了以前帖子中建议的所有显而易见的事情:
即在运行WatiN步骤之前杀死所有Internet Explorer进程:
Process.GetProcessesByName("IEXPLORE").ToList().ForEach(p => p.Kill());
Run Code Online (Sandbox Code Playgroud)
在运行任何WatiN步骤之前增加超时:
var timeout = 60;
Settings.AttachToBrowserTimeOut = timeout;
Settings.WaitForCompleteTimeOut = timeout;
Settings.WaitUntilExistsTimeOut = timeout;
Run Code Online (Sandbox Code Playgroud)
每个WatiN步骤都作为以下代码块中的操作传入:
public void UseAndCloseBrowser(Action<Browser> action, …Run Code Online (Sandbox Code Playgroud) 我在PHP上的AWS EC2实例上运行了我的Web应用程序,我进行了大约5-10分钟的ajax调用,我在Google Chrome中看到了Web控制台,我得到了这个 504 (Gateway Timeout),我怎么能增加这个值,是与apache有关?谢谢
我正在尝试为Alamofire for Swift的每个请求设置一个客户端超时.首席架构师告诉我在NSURLRequest上设置这个,但我对如何在实践中真正做到这一点感到困惑.
做过这个的人可以举个例子吗?谢谢!
我正在使用apache http客户端v4.5并将其用作REST客户端.在某些情况下,我识别出一个错误"[读取] I/O错误:读取超时",它来自httpclient框架,当它读取接收到的内容并将其显示为最后一条消息时.
它似乎没有影响,但我想知道是否有人知道它来自何处以及如何解决它.根据以下线程(链接),似乎是"mutlithreaded"配置的问题.
但是我只使用http客户端的默认配置,当我使用版本v4时,我不知道如何将"multithreaded"设置为false以查看它是否有任何区别.
我也试图设置超时但它没有帮助.
任何提示?
日志:
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "HTTP/1.1 200 OK[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Date: Tue, 29 Dec 2015 14:48:03 GMT[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Server: Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "X-Powered-By: PHP/5.6.8[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Cache-Control: nocache, private[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Content-Length: 99[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 …Run Code Online (Sandbox Code Playgroud) java multithreading timeout httpclient apache-httpcomponents
我正在尝试使用Slack Custom命令,并且不太确定如何使用延迟消息,因为Yoda Speak External API需要3秒以上的响应时间.
我做了以下事情:
/Yoda在我的情况下发送了slack命令并收到了reponse_url.post对响应URL 使用以下内容.Run Code Online (Sandbox Code Playgroud)$data_string = '{"response_type": "in_channel", "text":"Checking,please wait..."}' ; $chs = curl_init(); curl_setopt($chs, CURLOPT_URL, $response_url); curl_setopt($chs, CURLOPT_POST, true); curl_setopt($chs, CURLOPT_POSTFIELDS, $data_string); curl_setopt($chs, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($chs, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($chs, CURLOPT_RETURNTRANSFER, true); curl_setopt($chs, CURLOPT_POST, 1); curl_setopt($chs, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); $results = curl_exec($chs);
Run Code Online (Sandbox Code Playgroud)$chsres = curl_init(); curl_setopt($chsres, CURLOPT_URL, "https://yoda.p.mashape.com/yoda?sentence=welcome+to+stack"); curl_setopt($chsres, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($chsres, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($chsres, CURLOPT_VERBOSE, true); curl_setopt($chsres, CURLOPT_TIMEOUT, 45); curl_setopt($chsres, CURLOPT_RETURNTRANSFER, true); curl_setopt($chsres, CURLOPT_HTTPHEADER, array('Content-Type:application/json', "X-Mashape-Key:> …