I have a basic dgram UDP server in NodeJS and I want to apply a load test to this server, using Artillery. However, I couldn't find a way to achieve this.
Artillery has engines such as HTTP, WebSocket, SocketIO and PlayWright. As I know, SocketIO and WebSocket TCP protocols. So, how do I do a UDP test with these engines?
One of those engines or another implementation of UDP protocol in NodeJS are welcomed in my case. Is there a way to achieve this?
My UDP server:
const UDP = require('dgram')
const server = UDP.createSocket('udp4')
const port = 2222
server.on('listening', () => {
// Server address it’s using to listen
const address = server.address()
console.log('Listining to ', 'Address: ', address.address, 'Port: ', address.port)
})
server.on('message', (message, info) => {
console.log('Message', message.toString())
const response = Buffer.from('Message Received')
//sending back response to client
server.send(response, info.port, info.address, (err) => {
if (err) {
console.error('Failed to send response !!')
} else {
console.log('Response send Successfully')
}
})
})
server.bind(port)
My Artillery config file:
config:
target: http://localhost:2222
phases:
- duration: 30
arrivalRate: 10
name: Warm up the API
- duration: 30
arrivalRate: 10
rampTo: 15
name: Ramp up to peak load
scenarios:
- name: WebSocket Test
engine: "socketio" # Enable the Socket.io engine
flow:
- emit:
channel: "message"
data: "Hello World"
I answered this question on Artillery's Github Discussions: https://github.com/artilleryio/artillery/discussions/2189. Quoting from my answer there: