socketcluster: Exchange not working
Hey guys,
For some reason, exchange publishing stopped working with SCC. I didn’t change anything except upgrading to SC 10 from 8 and our exchange system stopped working. Here is an example.
var SCWorker = require('socketcluster/scworker')
var express = require('express')
let SC = require('socketcluster-client')
class Worker extends SCWorker {
run() {
console.log(' >> Worker PID:', process.pid)
var environment = this.options.environment
var app = express()
var httpServer = this.httpServer
var scServer = this.scServer
let scExchange = this.exchange
httpServer.on('request', app)
let packet = {
success:1,
message:'Here is your erp data',
notify:'orders-edit-set-erp-transaction-data',
customer_id:1000
}
let soc = SC.connect({
hostname:<url>,
secure:true
})
soc.on('connect',() => {
soc.publish('1000',packet)
})
}
}
new Worker()
works but this does not
var SCWorker = require('socketcluster/scworker')
var express = require('express')
class Worker extends SCWorker {
run() {
console.log(' >> Worker PID:', process.pid)
var environment = this.options.environment
var app = express()
var httpServer = this.httpServer
var scServer = this.scServer
let scExchange = this.exchange
httpServer.on('request', app)
let packet = {
success:1,
message:'Here is your erp data',
notify:'orders-edit-set-erp-transaction-data',
customer_id:1000
}
this.exchange.publish('1000',packet)
}
}
new Worker()
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (28 by maintainers)
@MegaGM this change was intentional. There was an issue that if a regular SC instance would join the cluster in the middle of a sync round then the state of the cluster would get stuck and not sync properly because the new client was ‘active’ but all the other instances were stuck on a different phase. The client used to wrongly assume that the cluster was always ‘active’.
So the fix was to make it so that the client would use the last known phase of the cluster that way new instances that join are now always in agreement with all other instances.