I am trying to connect to Intersystems Cache CSP Websocket with the following line from the client:
var ws = new WebSocket("ws://" + window.location.host + "/path/ClassName.cls");
And I'm getting this error in chrome console:
WebSocket connection to 'ws://<server address>' failed: Error during WebSocket handshake: 'Connection' header is missing
The request headers:
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,he;q=0.6
Cache-Control:no-cache
Connection:Upgrade
Cookie:CSPWSERVERID=Cache for Windows (x86-64) 2013.1.1 (Build 501_1_13062) Sun Aug 11 2013 23:20:33 EDT
Host:<host-ip>
Origin:http://<host-ip>
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:<the key>
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
And the response headers:
Date:Tue, 04 Aug 2015 11:45:54 GMT
Sec-WebSocket-Accept:<some key>
Sec-WebSocket-Protocol:chat
Server:Microsoft-IIS/7.5
Transfer-Encoding:chunked
Upgrade:websocket
X-Powered-By:ASP.NET
The server is using IIS 7.5, which technically doesn't support WebSocket, but it seems that all the websocket headers are indeed in place, except one: "Connection":"Upgrade".
Is there any way to inject the "connection" header into the handshake response? Is there some client configuration that can disregard the missing header?
Thanks.
Unfortunately for WebSockets support you need IIS 8 + Windows 8 and Windows Server 2012
http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls?KEY=GCGI_oper_config#GCGI_websockets
Related
Summary: Unable to cache and use the cached audio via a Service Worker.
Trying to: cache relatively small audio files (2-3mb) using service worker and cache API. These are loaded/played via a HTML Audio element, which usually sets a 'range' header.
Problem: Service worker responds with the whole content, ignoring the range header, and the Audio element ignores the content and does not play.
Without service worker: server obeys the range header, sends partial content, Audio element is happy and plays the audio.
I am using Google Chrome 52.
Note: Solution appears to have been noted by mnot "Serve range requests from a complete cache entry" but has any browser implemented this? Or, is there any workaround??
Technical info
Chrome terminal stderr: [1:1:0603/164806:ERROR:render_media_log.cc(23)] MediaEvent: PIPELINE_ERROR demuxer: could not open
Chrome console error: Uncaught (in promise) DOMException: The element has no supported sources.
Chrome headers (with SW, 2 parts):
PART#1
GENERAL
Request URL:http://localhost:3333/audio.m4a
Request Method:GET
Status Code:200 OK (from ServiceWorker)
Remote Address:127.0.0.1:3333
RESPONSE
accept-ranges:bytes
connection:keep-alive
content-length:2449048
content-type:audio/x-m4a
date:Fri, 03 Jun 2016 10:14:02 GMT
etag:"56f8f953-255e98"
last-modified:Mon, 28 Mar 2016 09:28:51 GMT
server:nginx
x-content-type-options:nosniff
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
REQUEST
Provisional headers are shown
Accept-Encoding:identity;q=1, *;q=0
Range:bytes=0-
Referer:http://localhost:3333/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.10 Safari/537.36
PART #2
GENERAL
Request URL:http://localhost:3333/audio.m4a
Request Method:GET
Status Code:200 OK (from ServiceWorker)
Remote Address:127.0.0.1:3333
RESPONSE
accept-ranges:bytes
connection:keep-alive
content-length:2449048
content-type:audio/x-m4a
date:Fri, 03 Jun 2016 10:14:02 GMT
etag:"56f8f953-255e98"
last-modified:Mon, 28 Mar 2016 09:28:51 GMT
server:nginx
x-content-type-options:nosniff
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
REQUEST
Provisional headers are shown
Accept-Encoding:identity;q=1, *;q=0
Range:bytes=2392064-
Referer:http://localhost:3333/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.10 Safari/537.36
Chrome headers (without SW, 3 parts!):
PART #1
GENERAL
Request URL:http://localhost:3333/audio.m4a
Request Method:GET
Status Code:206 Partial Content
Remote Address:127.0.0.1:3333
RESPONSE
Connection:keep-alive
Content-Length:2449048
Content-Range:bytes 0-2449047/2449048
Content-Type:audio/x-m4a
Date:Fri, 03 Jun 2016 10:24:32 GMT
ETag:"56f8f953-255e98"
Last-Modified:Mon, 28 Mar 2016 09:28:51 GMT
Server:nginx
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-Protection:1; mode=block
REQUEST
Accept:*/*
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Host:localhost:3333
Range:bytes=0-
Referer:http://localhost:3333/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.10 Safari/537.36
PART #2
GENERAL
Request URL:http://localhost:3333/audio.m4a
Request Method:GET
Status Code:206 Partial Content
Remote Address:127.0.0.1:3333
RESPONSE
Connection:keep-alive
Content-Length:56984
Content-Range:bytes 2392064-2449047/2449048
Content-Type:audio/x-m4a
Date:Fri, 03 Jun 2016 10:24:32 GMT
ETag:"56f8f953-255e98"
Last-Modified:Mon, 28 Mar 2016 09:28:51 GMT
Server:nginx
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-Protection:1; mode=block
REQUEST
Accept:*/*
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Host:localhost:3333
If-Range:"56f8f953-255e98"
Range:bytes=2392064-2449047
Referer:http://localhost:3333/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.10 Safari/537.36
PART #3
GENERAL
Request URL:http://localhost:3333/audio.m4a
Request Method:GET
Status Code:206 Partial Content
Remote Address:127.0.0.1:3333
RESPONSE
Content-Length:2121368
Content-Range:bytes 327680-2449047/2449048
Content-Type:audio/x-m4a
Date:Fri, 03 Jun 2016 10:24:32 GMT
ETag:"56f8f953-255e98"
Last-Modified:Mon, 28 Mar 2016 09:28:51 GMT
Server:nginx
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-Protection:1; mode=block
REQUEST
Provisional headers are shown
Accept-Encoding:identity;q=1, *;q=0
Range:bytes=327680-
Referer:http://localhost:3333/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.10 Safari/537.36
Check out https://samdutton.github.io/samples/service-worker/prefetch-video/ which works around this issue by manually created ranged responses.
Fixing this is gated on figuring out what browsers should be doing here, and updating the service worker spec if needed.
I used IndexedDB to implement this functionality and results are pretty impressive. You can use localForage to store the audio file in database and later retrieve it in offline mode via blob src url.
request = new XMLHttpRequest();
request.open('GET', audioURL, true);
request.responseType = 'blob';
request.onreadystatechange = function(){
if (request.readyState === 4 && request.status === 200){
localforage.setItem('KeyName', request.response).then(function(savedAudioBlob) { console.log('Saved Blob URL ' + savedAudioBlob); }); }
I am trying to make a websocket connection from Strophe.js to Ejabberd but ejabberd is not able to make a websocket connection.
Here is the detail:
ejabberd version: 16.02
Web socket headers
General
Request URL:ws://localhost:5280/websocket
Request Method:GET
Status Code:101 Switching Protocols
Response Headers
Connection:Upgrade
Sec-WebSocket-Accept:BHzI4XS3kPDZJhNt4BVAaGDvv8I=
Sec-Websocket-Protocol:xmpp
Upgrade:websocket
Request Headers
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:Upgrade
Host:localhost:5280
Origin:http://localhost
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:eErMAKwTSckMghBGWY3KtQ==
Sec-WebSocket-Protocol:xmpp
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Ejabberd websocket configuration
port: 5280
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
## "/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
## register: true
captcha: false
ejabberd logs
2016-03-22 15:32:46.765 [info] <0.438.0>#ejabberd_listener:accept:333 (#Port<0.16207>) Accepted connection 127.0.0.1:57946 -> 127.0.0.1:5280
2016-03-22 15:32:46.766 [info] <0.1283.0>#ejabberd_http:init:158 started: {gen_tcp,#Port<0.16207>}
2016-03-22 15:32:46.777 [error] <0.1286.0>#ejabberd_hooks:run_fold1:368 {{badmatch,[<<"localhost">>]},[{mod_pubsub,serverhost,1,[{file,"src/mod_pubsub.erl"},{line,4012}]},{mod_pubsub,plugins,1,[{file,"src/mod_pubsub.erl"},{line,4038}]},{mod_pubsub,features,2,[{file,"src/mod_pubsub.erl"},{line,4116}]},{mod_pubsub,disco_local_features,5,[{file,"src/mod_pubsub.erl"},{line,512}]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run_fold1,4,[{file,"src/ejabberd_hooks.erl"},{line,365}]},{mod_caps,make_my_disco_hash,1,[{file,"src/mod_caps.erl"},{line,515}]},{mod_caps,caps_stream_features,2,[{file,"src/mod_caps.erl"},{line,188}]}]}
running hook: {disco_local_features,[{jid,<<>>,<<"localhost">>,<<>>,<<>>,<<"localhost">>,<<>>},{jid,<<>>,<<"localhost">>,<<>>,<<>>,<<"localhost">>,<<>>},<<>>,<<>>]}
Please help me out to understand the ejabberd log and how can I make the successful websocket connection from client to ejabberd.
It seems this is not related to Websockets, but you seem to have hit a bug that is already fix in ejabberd repository and that will be packaged as 16.03.
If you update to latest HEAD from ejabberd repository, it should solve your pubsub crash issue.
You can find it here: https://github.com/processone/ejabberd
How could I set a reverse proxy with caddy that speak with a crossbar router?
I have a docker with a crossbar router that listen on localhost 8080, and I use caddy as a reverse proxy.
Below the Caddyfile:
`0.0.0.0:80
proxy /ws localhost:8080{
proxy_header Connection {>Connection}
proxy_heade Upgrade {>Upgrade}
}
header /ws {
Upgrade "WebSoket"
Connection "Upgrade"
}`
'tcpflow 8080' return nothing when I try to connect.
Below the header from chrome:
RESPONSE
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-Websocket-Accept: r/PdCQJibmcb5XrfVbnSXJMuf9g=
Sec-Websocket-Protocol: wamp.2.json
Server: Caddy
Server: Crossbar/0.11.1
Upgrade: WebSocket
X-Powered-By: AutobahnPython/0.10.9
Date: Tue, 09 Feb 2016 14:12:04 GMT
REQUEST
GET ws://78.46.244.23/ws HTTP/1.1
Host: 78.46.244.23
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: chrome://newtab
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTM
like Gecko) Chrome/48.0.2564.103 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Sec-WebSocket-Key: OaEUxWnqjZWyfLypeYxeXw==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: wamp.2.json
Below the frame:
[1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"progressive_call_results":true}},"publisher":{"features":{"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"publisher_identification":true}},"subscriber":{"features":{"publisher_identification":true}}}}]
And the console error:
WebSocket connection to 'ws://78.46.244.23/ws' failed: Invalid frame header
you have a typo in your Caddyfile:
Upgrade "WebSoket"
I'm trying to download a zipped file from Amazon Datafeed url and then decompress it.
This is my code:
open('public/files/amazon_ce.xml', 'w') do |local_file|
open('https://assoc-datafeeds-eu.amazon.com/datafeed/it_amazon_ce.xml.gz', :http_basic_authentication=>[USERNAME, PASSWORD]) do |remote_file|
local_file.write(Zlib::GzipReader.new(remote_file).read)
end
end
If I try with another file everything is ok, but not with this Amazon file: the error is:
OpenURI::HTTPError: 500 Internal Server Error
I logged the request when I download the same file using the browser...
GET /datafeed/getFeed?filename=it_amazon_ce.xml.gz HTTP/1.1
Host: assoc-datafeeds-eu.amazon.com:443
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: xxxxx
Referer: https://assoc-datafeeds-eu.amazon.com/datafeed/listFeeds?format=text/html
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
HTTP/1.1 302 Moved Temporarily
Cache-Control: no-cache
Content-Length: 0
Date: Wed, 30 Sep 2015 21:24:22 GMT
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Location: http://prod-deamazon.outputs.datafeeds.s3.amazonaws.com/it_amazon_dvd.xml.gz?Signature=xxxx&AWSAccessKeyId=xxxx&Expires=xxxx
Pragma: No-cache
Server: Apache-Coyote/1.1
Any idea?
Your browser is already authenticated and has a cookie which allows you to download the file.
You need to make sure that your Rails app has proper credentials to download the file (I can't in my browser, it asks for username/password)
I have read almost all of the questions on this, but found no solution. The error I got is 500 Internal Service Error which points to a specific error: CS0103: The name 'ViewBag' does not exist in the current context.
The strange thing is this error only occurs when an ajax call is made. When there is no ajax call involved, the same cshtml page works fine.
Here are the two responses with one that works(first) and the other fails(second):
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:localhost
Pragma:no-cache
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Response Headersview source
Access-Control-Allow-Origin:Access-Control-Allow-Origin
Cache-Control:private
Content-Encoding:gzip
Content-Length:7033
Content-Type:text/html; charset=utf-8
Date:Mon, 10 Feb 2014 19:25:49 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
Request Method:GET
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:localhost
Pragma:no-cache
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parametersview sourceview URL encoded
quarter:1
year:1
Response Headersview source
Access-Control-Allow-Origin:Access-Control-Allow-Origin
Cache-Control:private
Content-Length:48466
Content-Type:text/html; charset=utf-8
Date:Mon, 10 Feb 2014 19:28:29 GMT
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
Please help!