我是android开发人员和我的应用程序请求到我的服务器下载文件
Log.d("SBP", f_url[0]);
URL url = new URL(f_url[0]);
URLConnection conection = url.openConnection();
在debuge中显示一个请求,但在服务器中,当我打开access.log时,我看到2个或更多相同的请求! :|
但为什么???
这是我的nginx.config
user nginx;
worker_processes 1;
worker_rlimit_nofile 20000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
它是我的网站配置:
server {
server_name MYSITE;
access_log /srv/www/MYSITE/logs/access.log;
error_log /srv/www/MYSITE/logs/error.log;
root /srv/www/MYSITE/public;
client_max_body_size 20m;
client_body_buffer_size 128k;
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location / {
index index.html index.htm index.php;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location ~* \.php$ {
# include /etc/nginx/fastcgi_params;
server_tokens off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
答案 0 :(得分:0)
你的问题是由Volley RetryPolicy
引起的。要修复它(如there和there所示),您需要禁用重试尝试:
myRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
0,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
或增加超时(在此示例中为10秒而不是默认值2.5):
myRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 4,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));