permission denied #604
Answered
by
FZambia
ljfreelancer88
asked this question in
Q&A
-
I got this config.json {
"port": 8001,
"token_hmac_secret_key": "1558ec78-bd27-4851-800c-93d5ad4463cb",
"api_key": "73d302e6-e06e-4dcf-b94f-968a5ad9f60a",
"allow_subscribe_for_client": true,
"admin": true,
"admin_password": "b2cf2be7-1aad-4710-b874-c8a6f2d7c946",
"admin_secret": "c69f1422-506f-48f6-a4f1-a42a0f1a3afa",
"internal_port": 8002,
"allowed_origins": ["http://centrifugo.local"],
"namespaces": [
{
"name": "shop"
}
]
} NGINX upstream centrifugo {
server 127.0.0.1:8001;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name centrifugo.local www.centrifugo.local;
root /var/www/html/centrifugo;
index index.html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ /\.(?!well-known).* {
deny all;
}
location /connection/websocket {
proxy_pass http://centrifugo;
proxy_http_version 1.1;
proxy_buffering off;
keepalive_timeout 65;
proxy_read_timeout 60s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
} HTML <html>
<head>
<title>Centrifugo quick start</title>
</head>
<body>
<div id="counter">-</div>
<textarea name="message" class="js-message"></textarea>
<button type="button" class="js-send">Send</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/centrifuge/3.1.0/centrifuge.min.js"
integrity="sha512-GjNPYIUOKXvIx+PV/MnX3L3zHj7uRissT3R9bPJsbs7xFjMthNkHkd3QOAsDShtISRBHdGLy1sgm2maXaSDNxg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script type="text/javascript">
const container = document.getElementById('counter');
const centrifuge = new Centrifuge('ws://' + window.location.host + '/connection/websocket', {
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM3MjIiLCJleHAiOjE2NzQwNTg0NzZ9.teQSCp3pglhcdbkMza6lGUt8RsS1F8fEGbVF8x844i0"
});
centrifuge.on('connecting', function (ctx) {
console.log(`connecting: ${ctx.code}, ${ctx.reason}`);
}).on('connected', function (ctx) {
console.log(`connected over ${ctx.transport}`);
}).on('disconnected', function (ctx) {
console.log(`disconnected: ${ctx.code}, ${ctx.reason}`);
}).connect();
const sub = centrifuge.newSubscription("shop");
sub.on('publication', function (ctx) {
container.innerHTML = ctx.data.value;
document.title = ctx.data.value;
}).on('subscribing', function (ctx) {
console.log(`subscribing: ${ctx.code}, ${ctx.reason}`);
}).on('subscribed', function (ctx) {
console.log('subscribed', ctx);
}).on('unsubscribed', function (ctx) {
console.log(`unsubscribed: ${ctx.code}, ${ctx.reason}`);
}).subscribe();
let messageInput = document.querySelector('.js-message');
document.querySelector('.js-send')?.addEventListener('click', () => {
let message = messageInput.value;
if (!message) {
return;
}
console.log(message);
sub.publish({ 'message': message });
message = '';
});
</script>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
Answered by
FZambia
Jan 12, 2023
Replies: 1 comment 3 replies
-
Hello @ljfreelancer88 You mean the error during a |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
FZambia
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @ljfreelancer88
You mean the error during a
publish
?