6
Sono in esecuzione un server Express e sto utilizzando browserSync per controllare le modifiche. Quando eseguo npm start
, che prende il via un compito sorso che corre:BrowserSync continuo Ottieni utilizzando Express/Gulp
// Server task
gulp.task('server', function(cb) {
// We use this `called` variable to make sure
// the callback is only executed once
var called = false;
return nodemon({
script: 'server.js',
watch: ['server.js', 'app/**/*.js', 'config/**/*.js']
})
.on('start', function onStart() {
if (!called) {
cb();
}
called = true;
})
.on('restart', function onRestart() {
// Also reload the browsers after a slight delay
setTimeout(function reload() {
browserSync.reload({
stream: false
});
}, 500);
});
});
// BrowserSync
gulp.task('browser-sync', ['server'], function() {
browserSync.init({
// All of the following files will be watched
files: ['public/**/*.*'],
// Tells BrowserSync on where the express app is running
proxy: 'http://localhost:3000',
port: 4000,
open: false,
notify: false,
logPrefix: project.name,
logConnections: false,
logLevel: 'silent'
});
});
Tuttavia, nella finestra del terminale, continua a visualizzare il seguente:
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521010-28291 200 10.482 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521032-28292 200 10.573 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521053-28293 200 8.754 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521082-28294 200 7.013 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521110-28295 200 8.339 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521134-28296 200 12.367 ms
cosa sta causando questo? Come posso risolvere questo?
Non sembra un problema, solo una nota che la sincronizzazione del browser sta eseguendo il polling per le modifiche nel caso in cui qualsiasi cosa debba essere ricaricata. Quale dispositivo stai accedendo al server? Forse non hanno ancora socket Web e quindi ricadono su una chiamata polling XHR. – ddprrt
si sta definendo localhost: 3000 (3000 è la porta) e quindi si imposta la porta: 4000 sulla riga successiva ... suona strano –
Questo perché '' browserSync.init() '' avvia un proxy su localhost: 3000 su una porta diversa (4000). Non sono sicuro del motivo per cui sputa così tante richieste GET. Fa qualcosa di simile alla mia fine ed è fastidioso. – Wenzil