Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
0cf6b62c
Commit
0cf6b62c
authored
Nov 10, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the error handler for load error (403), to use a different timer to try reconnection
parent
f2ed355f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
pushstream.js
misc/js/pushstream.js
+32
-16
No files found.
misc/js/pushstream.js
View file @
0cf6b62c
...
@@ -146,7 +146,7 @@
...
@@ -146,7 +146,7 @@
EventSourceWrapper
.
prototype
=
{
EventSourceWrapper
.
prototype
=
{
connect
:
function
()
{
connect
:
function
()
{
this
.
disconnect
();
this
.
_closeCurrentConnection
();
var
url
=
getSubscriberUrl
(
this
.
pushstream
,
this
.
pushstream
.
urlPrefixEventsource
);
var
url
=
getSubscriberUrl
(
this
.
pushstream
,
this
.
pushstream
.
urlPrefixEventsource
);
this
.
connection
=
new
window
.
EventSource
(
url
);
this
.
connection
=
new
window
.
EventSource
(
url
);
this
.
connection
.
onerror
=
linker
(
this
.
onerror
,
this
);
this
.
connection
.
onerror
=
linker
(
this
.
onerror
,
this
);
...
@@ -158,16 +158,22 @@
...
@@ -158,16 +158,22 @@
disconnect
:
function
()
{
disconnect
:
function
()
{
if
(
this
.
connection
)
{
if
(
this
.
connection
)
{
Log4js
.
debug
(
"
[EventSource] closing connection to:
"
,
this
.
connection
.
URL
);
Log4js
.
debug
(
"
[EventSource] closing connection to:
"
,
this
.
connection
.
URL
);
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onclose
();
}
},
_closeCurrentConnection
:
function
()
{
if
(
this
.
connection
)
{
try
{
this
.
connection
.
close
();
}
catch
(
e
)
{
/* ignore error on closing */
}
try
{
this
.
connection
.
close
();
}
catch
(
e
)
{
/* ignore error on closing */
}
this
.
connection
=
null
;
this
.
connection
=
null
;
this
.
pushstream
.
_onclose
();
}
}
},
},
onerror
:
function
(
event
)
{
onerror
:
function
(
event
)
{
Log4js
.
info
(
"
[EventSource] error (disconnected by server):
"
,
event
);
Log4js
.
info
(
"
[EventSource] error (disconnected by server):
"
,
event
);
this
.
disconnect
();
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onerror
({
type
:
"
timeout
"
});
this
.
pushstream
.
_onerror
({
type
:
(
this
.
pushstream
.
readyState
===
PushStream
.
CONNECTING
)
?
"
load
"
:
"
timeout
"
});
},
},
onopen
:
function
()
{
onopen
:
function
()
{
...
@@ -195,7 +201,7 @@
...
@@ -195,7 +201,7 @@
StreamWrapper
.
prototype
=
{
StreamWrapper
.
prototype
=
{
connect
:
function
()
{
connect
:
function
()
{
this
.
disconnect
();
this
.
_closeCurrentConnection
();
var
domain
=
extract_xss_domain
(
this
.
pushstream
.
host
);
var
domain
=
extract_xss_domain
(
this
.
pushstream
.
host
);
try
{
try
{
document
.
domain
=
domain
;
document
.
domain
=
domain
;
...
@@ -211,13 +217,19 @@
...
@@ -211,13 +217,19 @@
disconnect
:
function
()
{
disconnect
:
function
()
{
if
(
this
.
connection
)
{
if
(
this
.
connection
)
{
Log4js
.
debug
(
"
[Stream] closing connection to:
"
,
this
.
url
);
Log4js
.
debug
(
"
[Stream] closing connection to:
"
,
this
.
url
);
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onclose
();
}
},
_closeCurrentConnection
:
function
()
{
if
(
this
.
connection
)
{
try
{
this
.
connection
.
onload
=
null
;
this
.
connection
.
setAttribute
(
"
src
"
,
""
);
}
catch
(
e
)
{
/* ignore error on closing */
}
try
{
this
.
connection
.
onload
=
null
;
this
.
connection
.
setAttribute
(
"
src
"
,
""
);
}
catch
(
e
)
{
/* ignore error on closing */
}
this
.
pingtimer
=
clearTimer
(
this
.
pingtimer
);
this
.
pingtimer
=
clearTimer
(
this
.
pingtimer
);
this
.
frameloadtimer
=
clearTimer
(
this
.
frameloadtimer
);
this
.
frameloadtimer
=
clearTimer
(
this
.
frameloadtimer
);
this
.
connection
=
null
;
this
.
connection
=
null
;
this
.
transferDoc
=
null
;
this
.
transferDoc
=
null
;
if
(
typeof
window
.
CollectGarbage
===
'
function
'
)
window
.
CollectGarbage
();
if
(
typeof
window
.
CollectGarbage
===
'
function
'
)
window
.
CollectGarbage
();
this
.
pushstream
.
_onclose
();
}
}
},
},
...
@@ -275,16 +287,14 @@
...
@@ -275,16 +287,14 @@
},
},
frameerror
:
function
(
event
)
{
frameerror
:
function
(
event
)
{
var
error
=
{};
Log4js
.
info
(
"
[Stream]
"
+
(
event
&&
(
event
.
type
===
"
load
"
))
?
"
frame loaded whitout streaming
"
:
"
frame load timeout
"
);
error
.
type
=
(
event
&&
(
event
.
type
===
"
load
"
))
?
"
load
"
:
"
timeout
"
;
this
.
_closeCurrentConnection
();
Log4js
.
info
(
"
[Stream]
"
+
(
error
.
type
===
"
load
"
)
?
"
frame loaded whitout streaming
"
:
"
frame load timeout
"
);
this
.
pushstream
.
_onerror
({
type
:
(
event
&&
(
event
.
type
===
"
load
"
))
?
"
load
"
:
"
timeout
"
});
this
.
disconnect
();
this
.
pushstream
.
_onerror
(
error
);
},
},
pingerror
:
function
()
{
pingerror
:
function
()
{
Log4js
.
info
(
"
[Stream] ping timeout
"
);
Log4js
.
info
(
"
[Stream] ping timeout
"
);
this
.
disconnect
();
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onerror
({
type
:
"
timeout
"
});
this
.
pushstream
.
_onerror
({
type
:
"
timeout
"
});
},
},
...
@@ -312,7 +322,7 @@
...
@@ -312,7 +322,7 @@
LongPollingWrapper
.
prototype
=
{
LongPollingWrapper
.
prototype
=
{
connect
:
function
()
{
connect
:
function
()
{
this
.
disconnect
();
this
.
_closeCurrentConnection
();
this
.
connectionEnabled
=
true
;
this
.
connectionEnabled
=
true
;
this
.
_listen
();
this
.
_listen
();
this
.
onopen
();
this
.
onopen
();
...
@@ -330,11 +340,17 @@
...
@@ -330,11 +340,17 @@
this
.
connectionEnabled
=
false
;
this
.
connectionEnabled
=
false
;
if
(
this
.
connection
)
{
if
(
this
.
connection
)
{
Log4js
.
debug
(
"
[LongPolling] closing connection to:
"
,
this
.
xhrSettings
.
url
);
Log4js
.
debug
(
"
[LongPolling] closing connection to:
"
,
this
.
xhrSettings
.
url
);
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onclose
();
}
},
_closeCurrentConnection
:
function
()
{
if
(
this
.
connection
)
{
try
{
this
.
connection
.
abort
();
}
catch
(
e
)
{
/* ignore error on closing */
}
try
{
this
.
connection
.
abort
();
}
catch
(
e
)
{
/* ignore error on closing */
}
this
.
connection
=
null
;
this
.
connection
=
null
;
this
.
lastModified
=
null
;
this
.
lastModified
=
null
;
this
.
xhrSettings
.
url
=
null
;
this
.
xhrSettings
.
url
=
null
;
this
.
pushstream
.
_onclose
();
}
}
},
},
...
@@ -359,8 +375,8 @@
...
@@ -359,8 +375,8 @@
this
.
_listen
();
this
.
_listen
();
}
else
{
}
else
{
Log4js
.
info
(
"
[LongPolling] error (disconnected by server):
"
,
status
);
Log4js
.
info
(
"
[LongPolling] error (disconnected by server):
"
,
status
);
this
.
disconnect
();
this
.
_closeCurrentConnection
();
this
.
pushstream
.
_onerror
({
type
:
"
timeout
"
});
this
.
pushstream
.
_onerror
({
type
:
(
status
===
403
)
?
"
load
"
:
"
timeout
"
});
}
}
}
}
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment