寻求一些帮助,我目前编写了一个HTTP服务器.它目前正在处理GET请求.然而,在使用POST时,缓冲的阅读器似乎挂了.当请求停止时,通过缓冲读取器读取其余输入流.我在谷歌上发现了一些东西.我已经尝试将CRLF和协议版本从1.1更改为1.0(浏览器自动发出请求为1.1)任何想法或帮助将不胜感激.谢谢
在大多数情况下,我的HTTP请求工作没有问题.但是,他们偶尔会挂起来.
我正在使用的代码设置为如果请求成功(响应代码为200或201),则调用screen.requestSucceeded().如果请求失败,则调用screen.requestFailed().
但是,当请求挂起时,它会在调用上述方法之一之前执行此操作.我的代码有问题吗?我应该使用某种最佳做法来防止任何悬挂吗?
以下是我的代码.我将不胜感激任何帮助.谢谢!
HttpConnection connection = (HttpConnection) Connector.open(url
+ connectionParameters);
connection.setRequestMethod(method);
connection.setRequestProperty("WWW-Authenticate",
"OAuth realm=api.netflix.com");
if (method.equals("POST") && postData != null) {
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", Integer
.toString(postData.length));
OutputStream requestOutput = connection.openOutputStream();
requestOutput.write(postData);
requestOutput.close();
}
int responseCode = connection.getResponseCode();
System.out.println("RESPONSE CODE: " + responseCode);
if (connection instanceof HttpsConnection) {
HttpsConnection secureConnection = (HttpsConnection) connection;
String issuer = secureConnection.getSecurityInfo()
.getServerCertificate().getIssuer();
UiApplication.getUiApplication().invokeLater(
new DialogRunner(
"Secure Connection! Certificate issued by: "
+ issuer));
}
if (responseCode != 200 && responseCode != 201) {
screen.requestFailed("Unexpected …
Run Code Online (Sandbox Code Playgroud) 我有Visual Studio 2010 Ultimate SP1,我的项目基于MFC.
当我调试我的项目的下一个代码时Visual Studio挂起:
CWnd* _window = CWnd::FromHandle(_hwnd_);
if (_window) {
DWORD nForeThread, nAppThread;
nForeThread = ::GetWindowThreadProcessId(::GetForegroundWindow(), 0);
nAppThread = GetCurrentThreadId();
if (nForeThread != nAppThread)
{
AttachThreadInput(nForeThread, nAppThread, TRUE);
_window->BringWindowToTop();
_window->ShowWindow(SW_RESTORE);
AttachThreadInput(nForeThread, nAppThread, FALSE);
}
else
{
_window->BringWindowToTop();
_window->ShowWindow(SW_RESTORE);
}
}
Run Code Online (Sandbox Code Playgroud)
我在下一行有一个断点:
AttachThreadInput(nForeThread, nAppThread, TRUE);
Run Code Online (Sandbox Code Playgroud)
因此,如果我按下F10或F11或F5按钮,则VS会立即挂起.
可能是什么问题呢?
我创建了一个包含一个组件的新包(TSpeedButton的后代),编译了包并将其安装在IDE(Delphi XE3 Pro)中.
它已经测试了它(我可以在设计和运行时使用我的组件).
但是:我关闭了IDE,现在我无法启动它.
它显示启动画面并显示进度:
最多All designtime packages loaded
(由德语翻译,YMMV).
我猜这是我的包裹,所以我删除了BPL.在下一次启动时,Delphi表示可以找到该软件包并询问是否应该在加载下一个项目时加载它; 我点击"否".
但是Delphi还没有启动,行为完全一样.启动Splashscreen并停止.
安装程序的"修复"选项也没有帮助.
老王
编辑:事实证明我太不耐烦了 - 重新启动就把它清理干净了.
我仍然标记肯肯怀特的答案,因为它本来是最后的解决方案.
这是一种非常奇怪的wget
行为.我在debian 7.2上.
wget -r -O - www.blankwebsite.com
Run Code Online (Sandbox Code Playgroud)
永远挂起来.我的意思是它挂起,它不是通过互联网搜索,我可以验证它strace
.如果我这样做:
while read R
do
wget -r -O - www.blankwebsite.com
done < smallfile
Run Code Online (Sandbox Code Playgroud)
如果smallfile
包含一行,则命令会在几秒钟后退出.
我也尝试过
wget -r -O - localhost/test.html
Run Code Online (Sandbox Code Playgroud)
用空test.html
文件,结果相同.对我来说,这听起来像一个bug.
一切都正常运行变化-O -
具有-O myfile
或删除-r
.
我用过-O -
是因为我把输出传递给了grep
.
谁能解释一下呢?你见过类似的东西吗?
我是Android的新手,但遇到了问题。我使用android studio 2.3,一切都很好。但是一段时间后,我发现调试时某个应用程序挂起。它冻结并且工作非常缓慢。如果我关闭调试,该应用程序将正常运行。我试图清洁设备和工作室上的琴凳,但没有帮助。我将笔记本电脑放在一旁,然后继续在其他PC上工作。一开始一切都很好,但是问题又回来了。我不知道原因并解决它。有人遇到同样的问题吗?
????????? ?????????? ????????? ?? ?????? ???????。??? ???? ????????? ????????? ????????? ????????? ?? ?????? 个人电脑???? ???? ?????? ??????,?? ????????? ????????? ????????? ??????? ????,??????? ?? ?? ????????? ??? ????? ?????????
我在Delphi 2007中编写了应用程序,有时会挂起(甚至不是每周都有应用程序全天候运行).看起来主线程卡住了.有哪些方法可以找出导致此问题的原因?
应用程序是用Delphi 2007编写的,它使用RemObjects,DBExpress和Firebird,使用COM进行OPC通信.
我一直在试图弄清楚Java Timers的问题.我想知道这里是否有人可以提供帮助.任何诊断问题的帮助都非常感谢.
我有一个带有三个TimerTask类(A,B和Stopper)的简单程序.A和B分别每400ms和500ms重复运行一次.Stopper任务计划在2秒运行以关闭所有内容.定时器按预期触发,任务的run()方法按预期执行.但是,一旦执行了止动任务,我希望程序终止,但它只是在打印"所有任务和计时器取消,退出"后挂起.我已经尝试过使用jstack来诊断问题,但没有任何明显的东西可以表明什么,如果需要释放/停止/取消等等.
这是我的代码:
package com.example.experiments;
import java.util.Date;
/**
* A test timer class to check behavior of exit/hang issues
*/
public class TimerTest {
TimerTest(){
}
class TaskA extends java.util.TimerTask {
TaskA(){
}
public void run() {
System.err.println("A.run() called.");
if (!running){
System.err.println("A: calling this.cancel().");
this.cancel();
return;
}
}
public boolean cancel(){
System.err.println("Canceling TaskA");
return super.cancel();
}
}
class TaskB extends java.util.TimerTask {
TaskB(){
}
public void run(){
System.err.println("B.run() called.");
if (!running){
System.err.println("B: calling this.cancel().");
this.cancel();
return;
}
}
public …
Run Code Online (Sandbox Code Playgroud) 使用一行代码,我可以使VS2012始终崩溃.(通过"崩溃"我的意思是当我点击时Build
,Visual Studio无限期挂起,我必须从任务管理器中删除它.)这是代码(在自定义用户控件中):
public class TransparentPanel : System.Windows.Forms.Panel
{
protected override void OnPaintBackground(PaintEventArgs pe)
{
this.Invalidate(); //this is the offending line
}
}
Run Code Online (Sandbox Code Playgroud)
若要重现该问题,请基于上面的代码创建一个控件并将其添加到Windows窗体; 然后尝试Build Solution
."Build started ..."将显示在状态栏中,然后VS将立即永久冻结.我尝试使用devenv/log进行故障排除,但活动日志没有显示任何错误或警告.所以我的问题是,为什么这个代码对C#编译器来说是致命的?(它也会导致IDE出现问题.例如,添加此透明控件后,只要"表单设计器"处于打开状态,"属性"窗格就会冻结.)
问题:这个bug应该报告给微软吗?如果是这样,怎么样?(我试图在MS Connect网站上提交错误,但显然他们只接受VS2013的错误.)
[如果您想知道我尝试使用该行的背景,请继续阅读.]
我为应用程序创建了一个自定义(Windows窗体)控件.(我试图用部分透明的图像创建一个控件,其位置可以通过鼠标交互来改变.)我使用下面的代码,它给了我一个图像(在一个面板上),我正在寻找透明度:
public class TransparentPanel : System.Windows.Forms.Panel
{
public Image Image { get; set; }
protected override void OnPaint(PaintEventArgs pe)
{
Rectangle rect = new Rectangle(this.Location, this.Size);
if (Image != null)
pe.Graphics.DrawImage(Image, this.DisplayRectangle);
}
protected override void OnPaintBackground(PaintEventArgs pe)
{ …
Run Code Online (Sandbox Code Playgroud) 当我尝试从终端上运行的adb命令,尤其是adb devices
,adb kill-server
和adb start-server
它挂,我需要键入CTRL+C
退出proccess.无法将APK部署到物理或虚拟设备.有些东西是阻止adb进程/端口.我已经安装了防病毒软件并禁用了防火墙.
在下面的示例中,我键入了adb设备,终端显示我附加的设备列表并挂起.