Varnish(v-4.1.2)HTTP直播流停止

时间:2016-04-12 10:43:45

标签: varnish varnish-vcl varnish-4

几天前我已经在Debian 8.4 64bit上部署了Varnish 4.1.2 ...服务配置没问题,但是当我开始流式传输时,流式传输冻结60秒然后再次自动开始运行接下来的2或3分钟再次冻结60年代.. 虽然我在Varnish 3中没有遇到这个问题......

这是我的清漆4.1.2配置......

default.conf

> vcl 4.0;

import std; import directors; import querystring;

backend server1 {   .host = "192.168.4.1";   .probe = {
    .url = "/hls/newtv/index.m3u8";
    .interval  = 5s;
    .timeout   = 1s;
    .window    = 5;
    .threshold = 3;   } }

sub vcl_init {   new vdir = directors.round_robin();   vdir.add_backend(server1); }

sub vcl_recv {   set req.backend_hint = vdir.backend(); # send all traffic to the vdir director   set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");   set req.url = std.querysort(req.url);


  if (req.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset req.http.Cookie;
    return (hash);   }

  if (req.http.Authorization) {
    # Not cacheable by default
    return (pass);   }

  return (hash); } sub vcl_pipe {   if (req.http.upgrade) {
    set bereq.http.upgrade = req.http.upgrade;   }

  return (pipe); }

sub vcl_hash {

    if (req.method == "GET" || req.method == "HEAD") {
        hash_data(querystring.remove(req.url));
    }
    else {
        hash_data(req.url);
    }
    hash_data(req.http.host);
    return (lookup);

}

sub vcl_hit {

  if (obj.ttl >= 0s) {
    return (deliver);   }


  if (std.healthy(req.backend_hint)) {
    if (obj.ttl + 10s > 0s) {
      return (deliver);
    } else {
      return(fetch);
    }   } else {
      if (obj.ttl + obj.grace > 0s) {
      return (deliver);
    } else {
      return (fetch);
    }   } return (fetch); # Dead code, keep as a safeguard }

sub vcl_miss {   return (fetch); }

sub vcl_backend_response {   if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
    unset beresp.http.Surrogate-Control;
    set beresp.do_esi = true;   }

  if (bereq.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset beresp.http.set-cookie;   }

  if (bereq.url ~ "^[^?]*\.(m3u8)(\?.*)?$") {
    unset beresp.http.set-cookie;
    set beresp.do_stream = true;
    set beresp.do_gzip   = false;   }

  if (beresp.status == 301 || beresp.status == 302) {
    set beresp.http.Location = regsub(beresp.http.Location, ":[0-9]+", "");   }

  if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
    return (abandon);   }

  set beresp.grace = 6h;

  return (deliver); }

sub vcl_deliver {

  if (obj.hits > 0) { # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed
    set resp.http.X-Cache = "HIT";   } else { set resp.http.X-Cache = "MISS";   }

  set resp.http.X-Cache-Hits = obj.hits;

  return (deliver); }

sub vcl_purge {   if (req.method != "PURGE") {
    # restart request
    set req.http.X-Purge = "Yes";
    return(restart);   } }

sub vcl_synth {   if (resp.status == 720) {
    set resp.http.Location = resp.reason;
    set resp.status = 301;
    return (deliver);   } elseif (resp.status == 721) {
    set resp.http.Location = resp.reason;
    set resp.status = 302;
    return (deliver);   }

  return (deliver); }


sub vcl_fini {

  return (ok); }

和/ etc / default / varnish

START=yes
NFILES=131072
MEMLOCK=82000
DAEMON_OPTS="-a 192.168.2.1:80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

任何人都可以帮我解决问题!

提前感谢...

1 个答案:

答案 0 :(得分:0)

我不认为这是配置问题。这听起来像一个清漆虫,我建议你把它归档给官方的bugtracker。

如果您赶时间,我建议您尝试set beresp.do_stream = False,但我不相信会有所帮助。