我有一个典型的Silverlight应用程序与WCF服务,我使用slsvcutil.exe生成标准客户端代理与Web服务进行通信.我正在尝试编写单元测试,我正在尝试使用Silverlight单元测试框架和Moq来模拟代理并删除服务依赖项以进行测试.
我是Moq的新手,在模拟异步调用进行服务调用时,自动在模拟代理上自动引发各种已完成事件有很多麻烦.
为了使代理"可模拟",我为生成的代理调用及其完成的事件创建了自己的简单接口:
public interface IServiceProxy
{
void TestAsync(TestRequest request);
void TestAsync(TestRequest request, object userState);
event EventHandler<TestCompletedEventArgs> TestCompleted;
}
Run Code Online (Sandbox Code Playgroud)
我还将生成的代理对象子类化为实现该接口:
public class MyServiceProxy : GeneratedServiceClient, IServiceProxy, ICommunicationObject
{
// ... overloaded proxy constructors
}
Run Code Online (Sandbox Code Playgroud)
在查看Moq文档之后,我正在尝试设置模拟以期望TestAsync()调用并立即使用EventArgs中的结果引发TestCompleted事件:
[TestMethod]
public void Test_Returns_Expected()
{
var mockProxy = new Mock<IServiceProxy>();
var result = new TestResponse() { Value = true };
this.mockProxy.Setup(
p => p.TestAsync(It.IsAny<TestRequest>()))
.Raises(p => p.TestCompleted += null, new TestCompletedEventArgs(new object[] { result }, null, false, null));
// rest of …Run Code Online (Sandbox Code Playgroud) 我在服务器上间歇性地收到以下错误:
**Proxy Error**
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.
Reason: Error reading from remote server
Run Code Online (Sandbox Code Playgroud)
错误日志显示以下内容:
[Sun Feb 06 03:06:00 2011] [error] [client 82.43.154.57] proxy: Error reading from remote server returned by /login, referer: https://demo.XXXXX.us/
[Sun Feb 06 03:06:30 2011] [error] [client 82.43.154.57] (70007)The timeout specified has expired: proxy: error reading status line from remote server XXXXX.us
[Sun Feb 06 03:06:30 2011] [error] [client 82.43.154.57] …Run Code Online (Sandbox Code Playgroud) 我正试图在Windows中从代理服务器后面运行bundle install,但它无法运行.有什么地方我可以改变以实现它吗?
我知道代理是问题,因为它之前有效,而且这是唯一可能搞砸了事情的东西
我有几个服务器地址,如cdn1.website.com,cdn2.website.com,cdn3.website.com.他们每个人都持有simillar文件.
请求来到我的服务器,我想将其重定向或重写为随机的cdn服务器.可能吗 ?
我想用python创建一个非常简单的代理(主要是为了理解它是如何工作的).我在谈论一个通用的TCP代理,而不仅仅是http.我已经构建了以下代码,但是,它似乎只能以一种方式工作:即请求已发送但我从未得到答案.这是代码:
import socket
import argparse
#Args
parser = argparse.ArgumentParser(description='ProxyDescription')
parser.add_argument('-l', '--listen', action='store', help='Listening port', default=80, type=int)
parser.add_argument('destination', action='store', help='Destination host')
parser.add_argument('port', action='store', help='Destination port', type=int)
args = parser.parse_args()
#Server
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind(('', args.listen))
s1.listen(1)
conn1, addr1 = s1.accept()
#Client
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((args.destination, args.port))
s2.setblocking(0)
print "Connected by ", addr1
while 1:
datato = conn1.recv(1024)
if not datato:
print "breaking to"
break
s2.send(datato)
print "data send : " + datato
try:
datafrom = s2.recv(1024)
print "reveived data …Run Code Online (Sandbox Code Playgroud) 我能够解决客户端无法通过代理进行身份验证的问题,执行以下操作:
var proxy = WebRequest.GetSystemWebProxy();
proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
service.Proxy = proxy;
Run Code Online (Sandbox Code Playgroud)
这适用于Windows XP,但在Windows 7上我得到407(代理未经过身份验证的例外).有没有人知道区别是什么,更重要的是,我需要做些什么才能让它在两个操作系统上都能运行?
UPDATE
我让用户检查以下内容:
更新为BOUNTY
所以,我加了赏金.我可以从这里获得一个解决方案,或者只是另一种方法来通过Windows 7上的代理...
另一个更新
我不确定这是否有用,但我们也在做以下事情:
service.PreAuthenticate = true;
service.Url = "myurl";
service.Credentials = new NetworkCredential(txt_UserName.Text, txt_Password.Text);
Run Code Online (Sandbox Code Playgroud)
我的临时解决方案
这不是一个真正的解决方案,但现在有效.我使用app.config并将代理设置为默认值,使用ByPassList以便甚至不使用代理.这只是可行的,因为代理目前没有强大的防火墙.对于其他客户,我需要让上述工作
我有企业环境,所有http和https调用都在代理后面.
通过将http_proxy环境变量导出到.profile文件中,我能够解决命令行下载的一些问题.
但是在第一次运行之前下载Android源代码或类的Robolectric 2.2我失败了.我还没有CI设置,所以我只是想从想法中运行测试.
有谁知道热修复它?
我试图在IDEA设置中提供代理,我试图在运行配置中提供额外的环境变量.什么都没有帮助
UPD当我在Mac设置中指定代理时,它产生另一个错误: 无法在存储库sonatype中找到资源'org.sonatype.oss:oss-parent:pom:7'(https://oss.sonatype.org/content/groups/public /)
看起来我可能正在使用或缺少Robolectirc错误的传递依赖(我不使用maven或常春藤,我刚刚从maven中心下载了罐子)
UPD2没有,它只是暂停:传输文件时出错:操作超时
TL; DR如何通过SOCKS代理将本地驱动程序连接到spark群集.
我们有一个现场火花群集,它位于阻止大多数端口的防火墙后面.我们有ssh访问权限,所以我可以创建一个SOCKS代理ssh -D 7777 ....
当我的浏览器使用代理时,它适用于浏览web-UI,但我不知道如何让本地驱动程序使用它.
到目前为止我有这个,显然没有配置任何代理:
val sconf = new SparkConf()
.setMaster("spark://masterserver:7077")
.setAppName("MySpark")
new SparkContext(sconf)
Run Code Online (Sandbox Code Playgroud)
在抛出异常之前,会将这些消息记录16次.
15/01/20 14:43:34 INFO Remoting: Starting remoting
15/01/20 14:43:34 ERROR NettyTransport: failed to bind to server-name/ip.ip.ip.ip:0, shutting down Netty transport
15/01/20 14:43:34 INFO RemoteActorRefProvider$RemotingTerminator: Shutting down remote daemon.
15/01/20 14:43:34 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
15/01/20 14:43:34 INFO RemoteActorRefProvider$RemotingTerminator: Remote daemon shut down; proceeding with flushing remote transports.
15/01/20 14:43:34 INFO RemoteActorRefProvider$RemotingTerminator: …Run Code Online (Sandbox Code Playgroud) 我有一个Android项目,在Android Studio上使用Crashlytics with Fabric插件,设置文件的代理:
studio64.exe.vmoptions:
-Dhttps.proxyPort=8080
-Dhttps.proxyHost=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-Dhttps.proxyUser=xxxxx
-Dhttps.proxyPassword=xxxxxxxx
Run Code Online (Sandbox Code Playgroud)
gradle.properties:
systemProp.http.proxyPassword=xxxxx
systemProp.http.proxyHost=proxy-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
systemProp.http.proxyUser=xxxxxxxx
systemProp.http.proxyPort=8080
systemProp.https.proxyPassword=xxxxx
systemProp.https.proxyHost=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
systemProp.https.proxyUser=xxxxxxxx
systemProp.https.proxyPort=8080
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我无法登录插头,显示消息"无法连接到网络"
任何人有任何想法或可能解决这个问题?
我正在开发一个Express驱动的站点,它正在通过nginx代理.有时在浏览器中加载页面时,我会得到:
GET http://myapp.local/css/bootstrap.css net::ERR_CONTENT_LENGTH_MISMATCH
Run Code Online (Sandbox Code Playgroud)
如果我刷新页面,它通常会消失.但如果一遍又一遍地刷新,它会再次出现.
这里有什么问题?我该怎么做才能缩小这个问题的范围?这是我nginx对此服务器的配置:
server {
listen 80;
server_name www.myapp.local;
rewrite ^(.*) http://myapp.local$1 permanent;
}
server {
listen 80;
server_name myapp.local;
access_log /vagrant/nginx/logs/myapp.local/access.log;
error_log /vagrant/nginx/logs/myapp.local/error.log;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Run Code Online (Sandbox Code Playgroud)
这肯定与nginx代理有关.因为如果我只使用IP地址和节点端口访问该站点:http://10.10.10.10:8080那么我永远不会得到错误.但是,如果我使用代理vhost访问它:http://myapp.local那么我最终会得到错误(可能有十分之一的机会我看到它).
proxy ×10
android ×2
nginx ×2
.net-3.5 ×1
apache ×1
apache-spark ×1
asynchronous ×1
bundle ×1
c# ×1
cdn ×1
crashlytics ×1
credentials ×1
express ×1
gem ×1
install ×1
macos ×1
moq ×1
node.js ×1
python ×1
rewrite ×1
robolectric ×1
scala ×1
silverlight ×1
sockets ×1
ssh ×1
wcf ×1