Comments (10)
I cannot reproduce the issue:
const Primus = require('primus');
const http = require('http');
const fs = require('fs');
const server = http.createServer(function (req, res) {
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(__dirname + '/index.html').pipe(res);
});
const primus = new Primus(server, {
pathname: '/mycustompath/primus',
transformer: 'engine.io'
});
primus.on('connection', function (spark) {
console.log(spark.id, 'connected');
});
server.listen(3000, function () {
console.log('listening on port 3000');
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="/mycustompath/primus/primus.js"></script>
<script>
(function () {
var primus = new Primus({ strategy: false });
primus.on('open', function open() {
console.log('open');
});
})();
</script>
</body>
</html>
Did you rebuild the client?
from primus.
It does not matter, that is just where the Primus
client is found.
const Primus = require('primus');
const http = require('http');
const fs = require('fs');
const server = http.createServer(function (req, res) {
if (req.url === '/primus-client.js') {
res.setHeader('Content-Type', 'text/javascript');
fs.createReadStream(__dirname + '/primus-client.js').pipe(res);
return;
}
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(__dirname + '/index.html').pipe(res);
});
const primus = new Primus(server, {
pathname: '/mycustompath/primus',
transformer: 'engine.io'
});
primus.save(__dirname + '/primus-client.js');
primus.on('connection', function (spark) {
console.log(spark.id, 'connected');
});
server.listen(3000, function () {
console.log('listening on port 3000');
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="/primus-client.js"></script>
<script>
(function () {
var primus = new Primus({ strategy: false });
primus.on('open', function open() {
console.log('open');
});
})();
</script>
</body>
</html>
from primus.
It means the Primus
constructor is not found. Ensure that the client script it correctly loaded.
from primus.
I can't debug your code, sorry. That's up to you.
from primus.
You probably just have to save the client lib under the javascript folder and get it from there.
primus.save('/path/to/javascript/primus.js');
<script src="/path/to/javascript/primus.js"></script>
from primus.
That is a CORS issue because you are sending a cross origin request from https://app.autoscheduler.ai to https://api.autoscheduler.ai. See https://github.com/primus/primus#getting-started and https://github.com/socketio/engine.io#methods-1.
from primus.
Requests for primus/engine.io are not handled by express.
from primus.
No, server side.
from primus.
No, cors
is not a valid primus option. It should eventually be origins
but it depends on your architecture. Is https://api.autoscheduler.ai/ running primus? From the screenshots it seems to run a plain engine.io server. If so you should use the cors
option as per https://github.com/socketio/engine.io#methods-1 and things might not work as you expect if you use a primus client to connect to it.
from primus.
I'm closing this. Let me know if it should stay open.
from primus.
Related Issues (20)
- update documentation to be more explicit around createSocket
- Problem using proxy with primus client side
- Nativescript support HOT 1
- Does the primus web client work with a non-primus websocket server? HOT 4
- How can I know if a connection has been upgraded or not? HOT 4
- import primus client in client JS
- Getting response headers while polling HOT 3
- public connections and connected HOT 1
- Consider to rewrite without prototype pollution? HOT 11
- Primus with Koa and websockets transport HOT 3
- Can you please consider changing "Primus, the creator god of transformers" HOT 3
- async plugins support HOT 8
- support of the new uwebsocket version
- Allow Primus instance to select version of transformer/engine library
- Server Side Events (SSE) source HOT 7
- Maximum Concurrent Connection on Primus Server HOT 2
- Consider alternative to deprecated navigator.userAgent getter. HOT 1
- __name is not defined HOT 1
- Primus breaks Esc to close <dialog>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primus.