我正在使用蝗虫将消息写入队列。
这是我的代码
var numOne = prompt('Give me a number');
var numTwo = prompt('Give me another number');
alert('The sum of your numbers is ' + numOne+numTwo);
当我运行locust -f locust.py --host = localhost:8089时。我收到此错误
import requests
from locust import HttpLocust, TaskSet
from requests.auth import HTTPDigestAuth
import pika
import json
class UserBehavior(TaskSet):
def on_start(self):
pass
@task
def publish_message(self):
body='{"cmd":1,"key":"YW5zaHVsd2FsaWExMjhAZ21haWwuY29tOnRlc3QxOmFuc2h1bDEyMzo4Njk0MzAwNDg2MTUwOTk="}'
credentials = pika.PlainCredentials('user', 'pass')
connection = pika.BlockingConnection(pika.ConnectionParameters('ip',
5672,
'/',
credentials))
channel = connection.channel()
props=pika.BasicProperties(correlation_id="token", reply_to = "amq.gen-wDnl1fnJ7y2HhO9AjXdMvQ")
channel.basic_publish(exchange='',
routing_key='rpc_queue', body=body,
properties=props)
newbody='{"data":{"header":{"client_params":{"e_key_v":"V1","m_token_v":"header-1114099a-cc50-4c08-bbb9-72d9639d45414","st":-1},"attachments":{"count":"0","data":{}},"body":{"size":"24"},"subject":{"size":"2","content":" "},"control_params":{"priority":"3","restricted":"-1","ack":"-1","expiry":"-1"},"type":"1","folder":"inbox","to":{"1":"sanjeev"},"from":"abc","id":"new","token":"header-48197b90-5354-4be2-85e0-fab8c51d0d9511"},"body":"hi there"},"cmd":"2"}'
channel.basic_publish(exchange='',
routing_key='rpc_queue', body=newbody,
properties=props)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
该如何解决?任何帮助将不胜感激。