正如标题所暗示的那样,我试图理解为什么在WCF中有时人们选择"生成代理"而不是使用ChannelFactory来手动创建新的通道实例.我已经看过每个例子,但是没有真正找到任何解释为什么你会选择一个与另一个.
说实话,我只使用过频道和ChannelFactory<T>我继承的代码,即:
IChannelFactory<IDuplexSessionChannel> channelFactory =
binding.BuildChannelFactory<IDuplexSessionChannel>();
_duplexSessionChannel = channelFactory.CreateChannel(endpointAddress);
Run Code Online (Sandbox Code Playgroud)
那我为什么要"生成代理"呢?有什么好处和缺点?
我在mywebsite.com上为我的网站服务.我在flickr上托管图像,所以所有图像都通过获取flickr的请求加载到用户的浏览器中.我的许多网站用户从公司网络访问mywebsite.com,这阻止了对flickr.com的访问.这意味着用户会得到非常烦人的空白占位符而不是图像.我在Facebook按钮上遇到了同样的问题.这使得我的网站对这些用户看起来非常不吸引人.
有没有办法我可以运行客户端脚本,检查flickr.com,facebook.com等是否可访问.如果不是,我可以更改图像的href属性以从备用源加载,或者用标准图像替换,以解释其网络阻止访问.我也可以删除Facebook之类的按钮.
我认为XML http请求可以解决这个问题,但是我认为我遇到了跨域问题.我想我也可以设置代理服务图像,但我不想这样做; 这个想法是flickr带来了带宽.
TLDR:如何使用客户端技术确定是否可以从用户的浏览器访问flickr.com.
我正在尝试在nginx后面设置TeamCity.我想https://public.address.com/teamcity/ ...重定向到http://127.0.0.1:8111/ ...,但即使nginx成功完成此操作,登录页面也会返回看起来像这样的引用:
<script type="text/javascript" src="/res/-8762791360234593415.js?v=1305815890782"></script>
Run Code Online (Sandbox Code Playgroud)
显然,这不会做,并且摆弄rootURL设置(服务器URL:在服务器配置中)没有任何区别.
如何在非根URL下在代理后面运行TeamCity?
FWIW,这是我的nginx配置的相关部分:
location /teamcity/ {
proxy_pass http://127.0.0.1:8111/;
proxy_redirect http://127.0.0.1:8111/ https://$host/teamcity/;
}
Run Code Online (Sandbox Code Playgroud) 示例:我想创建一个 AutoResponse规则,将所有对一个主机的调用映射到另一个主机,但保留URL.例子
http://hostname1/foo.html - > http://hostname2/foo.html
和
http://hostname1/js/script.js - > http://hostname2/js/script.js
在一条规则中. 现在,我已经通过为项目调用的每个URL创建了一个N AutoResponse规则来实现这一点,但我确信必须有一种方法可以使用正确的通配符来修改一条规则.我查看了http://www.fiddler2.com/Fiddler2/help/AutoResponder.asp,但我看不出怎么做.外卡似乎都在匹配而不是动作.
完整的上下文: 我在一个测试平台和Visual Studio开发中borked这样远,它是将所有的请求HTTP://本地主机:24575当我的项目实际上是上运行的http://本地主机:56832
我正在使用Python和Selenium库编写测试套件.使用chromedriver,我使用以下方法设置代理:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % hostname + ":" + port)
global driver
driver = webdriver.Chrome(chrome_options=chrome_options)
Run Code Online (Sandbox Code Playgroud)
当代理没有身份验证时,这很好.但是,如果代理要求您使用用户名和密码登录,则无法使用.使用add_argument或其他方法将代理身份验证信息传递给chromedriver的正确和正确方法是什么?
它与以下内容不同:如何在Selenium Java中为Chrome设置代理设置
看作:
这是一个很常见的问题,但我无法找到解决我具体案例的方法.我正在使用Glassfish 4.1.1,我的应用程序实现了Websockets.
在客户端,我只是通过以下方式连接到WS-server:
var serviceLocation = "ws://" + window.location.host + window.location.pathname + "dialog/";
var wsocket = new WebSocket(serviceLocation + token_var);
Run Code Online (Sandbox Code Playgroud)
在服务器端,websockets通过@ServerEndpoint功能实现,看起来很常见:
@ServerEndpoint(value = "/dialog/{token}", decoders = DialogMessageDecoder.class)
public class DialogWebsoketEndpoint {
@OnOpen
public void open(final Session session, @PathParam("token") final String token) { ... }
etc.
}
Run Code Online (Sandbox Code Playgroud)
一切正常,直到客户试图连接代理后面的那一刻.使用此测试:http://websocketstest.com/我发现客户的计算机在http-proxy 1.1后面工作.他无法连接到websockets,onopen根本就不会开火.wsoscket.readyState永远不会成为1.
即使客户在代理后面连接,我如何调整我的ServerEndpoint以使此代码工作?
先感谢您!
更新:我会在该计算机上提供websocketstest的屏幕截图:
在我的计算机上似乎除了一件事之外:HTTP代理:否.
当我转到"安装新软件"并选择更新站点或转到"可用软件站点"并单击"重新加载"时,我收到"需要HTTP代理身份验证"错误.
我已经在网上搜索,我一直在尝试,发现类似的建议设置eclipse.ini与
-vmargs -Djava.net.preferIPv4Stack=true
-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient4
Run Code Online (Sandbox Code Playgroud)
我在Helios版本中设置了Neon链接,它显示可用软件没有错误.
http://download.eclipse.org/releases/neon
需要HTTP代理身份验证:http://download.eclipse.org/releases/neon/compositeContent.xml需要 HTTP代理身份验证:http://download.eclipse.org/releases/neon/compositeContent.xml需要 代理身份验证
我没有将Eclipse配置为针对任何代理进行身份验证.
版本:Neon Release(4.6.0)Build id:20160613-1800
Windows 7 64位
如何设置它?我在公司网络中,但我也在家中尝试使用相同的笔记本电脑,问题仍然存在.
NGINX代理将HTTP GET请求而不是WebSocket握手传递给我的django应用程序.
事实:
相关日志:
通过容器化nginx代理连接时的Daphne日志:
`xxx.xxx.xxx.xxx:40214 - - [24/May/2017:19:16:03] "GET /flight/all_flight_updates" 404 99`
Run Code Online (Sandbox Code Playgroud)
Daphne在绕过容器化代理并直接连接到服务器时进行日志记录:
xxx.xxx.xxx.xxx:6566 - - [24/May/2017:19:17:02] "WSCONNECTING /flight/all_flight_updates" - -
xxx.xxx.xxx.xxx:6566 - - [24/May/2017:19:17:02] "WSCONNECT /flight/all_flight_updates" - -
Run Code Online (Sandbox Code Playgroud)
nginx(非容器化)配置的localhost测试工作:
[2017/05/24 14:24:19] WebSocket HANDSHAKING /flight/all_flight_updates [127.0.0.1:65100]
[2017/05/24 14:24:19] WebSocket CONNECT /flight/all_flight_updates [127.0.0.1:65100]
Run Code Online (Sandbox Code Playgroud)
配置文件:
我的docker-compose.yml:
version: '3'
services:
db:
image: postgres
redis:
image: redis:alpine
web:
image: nginx
ports:
- '80:80'
volumes:
- ./deploy/proxy.template:/etc/nginx/conf.d/proxy.template
links:
- cdn
- app
command: /bin/bash -c "envsubst '' < …Run Code Online (Sandbox Code Playgroud) 我试图配置nginx代理将请求传递给另一个服务器,只有当$ request_body变量匹配特定的正则表达式.但它不适合我.
server{
listen 80 default;
server_name www.applozic.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
if ($request_body ~* (.*)appId(.*)) {
proxy_pass http://apps.applozic.com;
}
}
Run Code Online (Sandbox Code Playgroud)
}
请求正文是::
{
"applicationId": "appId",
"authenticationTypeId": 1,
"enableEncryption": false,
"notificationMode": 0,
"deviceType": 4,
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用下面的pip install命令,但它失败了代理身份验证需要问题.我已经在RHEL7.x服务器中配置了代理.
Command Used: `pip install --proxy https://'username:pwd'@proxy:host --upgrade pip`
Run Code Online (Sandbox Code Playgroud)
日志:
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after …Run Code Online (Sandbox Code Playgroud)