- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用以下代码时遇到错误。
我已经包含了 Sip 所需的所有 jar ;但是,我仍然不明白为什么会发生这个错误。你能给我解释一下吗?
我的代码类是:
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Random;
import javax.sip.DialogTerminatedEvent;
import javax.sip.IOExceptionEvent;
import javax.sip.ListeningPoint;
import javax.sip.RequestEvent;
import javax.sip.ResponseEvent;
import javax.sip.SipFactory;
import javax.sip.SipListener;
import javax.sip.SipProvider;
import javax.sip.SipStack;
import javax.sip.TimeoutEvent;
import javax.sip.TransactionTerminatedEvent;
import javax.sip.address.Address;
import javax.sip.address.AddressFactory;
import javax.sip.header.CSeqHeader;
import javax.sip.header.CallIdHeader;
import javax.sip.header.ContactHeader;
import javax.sip.header.FromHeader;
import javax.sip.header.HeaderFactory;
import javax.sip.header.MaxForwardsHeader;
import javax.sip.header.ToHeader;
import javax.sip.header.ViaHeader;
import javax.sip.message.MessageFactory;
import javax.sip.message.Request;
import javax.swing.JFrame;
public class SipClient extends JFrame implements SipListener
{
SipFactory sipFactory; // Used to access the SIP API.
SipStack sipStack; // The SIP stack.
SipProvider sipProvider; // Used to send SIP messages.
MessageFactory messageFactory; // Used to create SIP message factory.
HeaderFactory headerFactory; // Used to create SIP headers.
AddressFactory addressFactory; // Used to create SIP URIs.
ListeningPoint listeningPoint; // SIP listening IP address/port.
Properties properties; // Other properties.
String ip; // The local IP address.
int port = 6060; // The local port.
String protocol = "udp"; // The local protocol (UDP).
int tag = (new Random()).nextInt(); // The local tag.
Address contactAddress; // The contact address.
ContactHeader contactHeader; // The contact header.
public SipClient()
{
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN- BEGIN:initComponents
private void initComponents() {
scrollPane = new javax.swing.JScrollPane();
textArea = new javax.swing.JTextArea();
buttonRegisterStateless = new javax.swing.JButton();
buttonRegisterStatefull = new javax.swing.JButton();
buttonInvite = new javax.swing.JButton();
buttonBye = new javax.swing.JButton();
textField = new javax.swing.JTextField();
this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SIP Client");
setLocationByPlatform(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
onOpen(evt);
}
});
textArea.setEditable(false);
textArea.setColumns(20);
textArea.setRows(5);
scrollPane.setViewportView(textArea);
buttonRegisterStateless.setText("Reg (SL)");
buttonRegisterStateless.setEnabled(true);
buttonRegisterStateless.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onRegisterStateless(evt);
}
});
buttonRegisterStatefull.setText("Reg (SF)");
buttonRegisterStatefull.setEnabled(true);
buttonRegisterStatefull.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onRegisterStatefull(evt);
}
});
buttonInvite.setText("Invite");
buttonInvite.setEnabled(true);
buttonInvite.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onInvite(evt);
}
});
buttonBye.setText("Bye");
buttonBye.setEnabled(true);
buttonBye.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onBye(evt);
}
});
textField.setText("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G)
.addComponent(scrollPane)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonRegisterStateless, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonRegisterStatefull, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonInvite, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonBye, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 2, Short.MAX_VALUE))
.addComponent(textField))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonRegisterStateless)
.addComponent(buttonInvite)
.addComponent(buttonBye)
.addComponent(buttonRegisterStatefull))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void onOpen(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onOpen
try
{
this.ip=InetAddress.getLocalHost().getHostAddress();
System.out.println(ip);
this.sipFactory=SipFactory.getInstance();
this.sipFactory.setPathName("gov.nist");
this.properties=new Properties();
this.properties.setProperty("javax.sip.STACK_NAME", "myStack");
// Create the SIP stack.
this.sipStack = this.sipFactory.createSipStack(this.properties);
// Create the SIP message factory.
this.messageFactory = this.sipFactory.createMessageFactory();
// Create the SIP header factory.
this.headerFactory = this.sipFactory.createHeaderFactory();
// Create the SIP address factory.
this.addressFactory = this.sipFactory.createAddressFactory();
// Create the SIP listening point and bind it to the local IP address, port and protocol.
this.listeningPoint = this.sipStack.createListeningPoint(this.ip, this.port, this.protocol);
// Create the SIP provider.
this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint);
// Add our application as a SIP listener.
this.sipProvider.addSipListener(this);
// Create the contact address used for all SIP messages.
System.out.println("Local address: " + this.ip +" : "+ this.port + "\n");
this.contactAddress = this.addressFactory.createAddress("sip: "+ this.ip +" : "+ this.port);
// Create the contact header used for all SIP messages.
this.contactHeader = this.headerFactory.createContactHeader(contactAddress);
// Display the local IP address and port in the text area.
System.out.println("Local address: " + this.ip +" : "+ this.port + "\n");
}
catch(Exception e)
{
e.printStackTrace();
}
}//GEN-LAST:event_onOpen
private void onRegisterStateless(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRegisterStateless
try {
// Get the destination address from the text field.
Address addressTo = addressFactory.createAddress(textField.getText());
// Create the request URI for the SIP message.
javax.sip.address.URI requestURI = addressTo.getURI();
// Create the SIP message headers.
// The "Via" headers.
ArrayList viaHeaders = new ArrayList();
ViaHeader viaHeader = headerFactory.createViaHeader(ip, port, "udp", null);
viaHeaders.add(viaHeader);
// The "Max-Forwards" header.
MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
// The "Call-Id" header.
CallIdHeader callIdHeader = sipProvider.getNewCallId();
// The "CSeq" header.
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L,"REGISTER");
// The "From" header.
FromHeader fromHeader = headerFactory.createFromHeader(contactAddress, String.valueOf(tag));
// The "To" header.
ToHeader toHeader = headerFactory.createToHeader(addressTo, null);
// Create the REGISTER request.
Request request = messageFactory.createRequest(
requestURI,
"REGISTER",
callIdHeader,
cSeqHeader,
fromHeader,
toHeader,
viaHeaders,
maxForwardsHeader);
// Add the "Contact" header to the request.
request.addHeader(contactHeader);
// Send the request statelessly through the SIP provider.
sipProvider.sendRequest(request);
// Display the message in the text area.
textArea.append(
"Request sent:\n" + request.toString() + "\n\n");
}
catch(Exception e) {
// If an error occurred, display the error.
textArea.append("Request sent failed: " + e.getMessage() + "\n");
}
}//GEN-LAST:event_onRegisterStateless
private void onRegisterStatefull(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRegisterStatefull
// A method called when you click on the "Reg (SF)" button.
}//GEN-LAST:event_onRegisterStatefull
private void onInvite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onInvite
// A method called when you click on the "Invite" button.
}//GEN-LAST:event_onInvite
private void onBye(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onBye
// A method called when you click on the "Bye" button.
}//GEN-LAST:event_onBye
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new SipClient().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonBye;
private javax.swing.JButton buttonInvite;
private javax.swing.JButton buttonRegisterStatefull;
private javax.swing.JButton buttonRegisterStateless;
private javax.swing.JScrollPane scrollPane;
private javax.swing.JTextArea textArea;
private javax.swing.JTextField textField;
// End of variables declaration//GEN-END:variables
public void processRequest(RequestEvent requestEvent) {
// A method called when you receive a SIP request.
}
public void processResponse(ResponseEvent responseEvent) {
// A method called when you receive a SIP request.
}
public void processTimeout(TimeoutEvent timeoutEvent) {
// A method called when a SIP operation times out.
}
public void processIOException(IOExceptionEvent exceptionEvent) {
// A method called when a SIP operation results in an I/O error.
}
public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {
// A method called when a SIP transaction terminates.
}
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
// A method called when a SIP dialog terminates.
}
}
我也包含了 org.apache.log4j
jar,但我仍然收到以下错误:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at ServerClasses.sc.SipClient.onOpen(SipClient.java:169)
at ServerClasses.sc.SipClient.access$0(SipClient.java:159)
at ServerClasses.sc.SipClient$1.windowOpened(SipClient.java:77)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: gov.nist.javax.sip.SipStackImpl
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:305)
... 29 more
请帮我解决这个问题。我是 SIP 编程新手。
最佳答案
您需要 jain-sip-api 和 jain-sip-ri jar。通过查看错误,您缺少 ri jar。您可以从此处的存档中获取 jar https://jsip.ci.cloudbees.com/job/jsip/lastSuccessfulBuild/artifact/trunk/jain-sip-1.2.2370.tar.gz
关于java - 出现错误 javax.sip.PeerUnavailableException : The Peer SIP Stack: gov. nist.javax.sip.SipStackImpl 无法实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31073428/
让我先描述一下我的问题。我将 Sofia SIP 用于电话应用程序,而我使用的 SIP 代理位于 NAT 后面。这意味着来自代理的传入邀请将内部代理 IP(例如 10.0.0.1)作为 Contact
我试图找出 的可能值范围接受 和 接受-联系 header 字段,但我在 RFC 中找不到完整列表。有谁知道他们在哪里?我经常看到 Accept: application/sdp;level=1,
我使用的 SIP 服务器通过端口 5070 监听 SIP/TLS 请求。我正在尝试跟踪和分析为什么我的拨号器没有通过 Wireshark 在网络上注册。 我已经在 Wireshark 的首选项中编辑了
我一直非常坚持解决这个问题,我去过几乎所有谈论这个主题的网站(包括旧的堆栈溢出帖子),现在我正在尝试遵循 Android“官方”文档以便让我的 SIP 客户端在我的 Asterisk 服务器上注册,应
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我已经从一个 Asterisk(版本 11.2.1)创建了一个 sip 中继,说“A”服务器到另一个 Asterisk 服务器(11.7.0)说“B”,我得到 sip 响应 200 ok。 但是当我开
我几乎设法发起了一个 2 方通话(点击通话):第一个到我的办公室,第二个到我的手机,使用 Michal Niklas 回答(感谢 Michal) Asterisk click to call . 主要
本地和远程标记以及Call-ID的组合用于识别对话。据说Call-ID是一次调用的唯一值。那么为什么 Call-ID 不单独用于识别对话呢? 最佳答案 一句话:“发夹”。 “Hairpinning”是
我想在SIPBYE报头中获取Custom-Order的值。我尝试使用${sip_yee_h_Custom-Order},但它是空的,因为头名称前没有X前缀。。我可以编辑freeswitch sofia
我在使用以下代码时遇到错误。 我已经包含了 Sip 所需的所有 jar ;但是,我仍然不明白为什么会发生这个错误。你能给我解释一下吗? 我的代码类是: import java.net.InetAddr
我有一个 res_mysql.conf 配置为使用从 db.sql 文件重新填充的一些数据库 db。加载转储后,我重新加载配置,我的 SIP 对等点消失了: dev-ast*CLI> sip show
我正在制作 SIP 电话并且必须开发一个功能来支持多个注册。如果手机的主注册服务器关闭,手机应自动注册到辅助注册器,并在主注册器处于事件状态时再次返回主注册器。我的问题是:如何确定主注册商再次活跃起来
我正在尝试实现一个 sip 服务器以连接到 HTML sip 客户端(使用 sipml5 制作)。在我研究这样做的过程中,我遇到了 sip over web-sockets,这可能对我有用,但是,我不
我需要通过 Lua 脚本在 Kamailio 3.3.1 中设置自定义 header 。理论上我可以像这样在配置脚本中设置一个 - append_hf("X-MyHeader: myvalue\r\n
我需要通过 Lua 脚本在 Kamailio 3.3.1 中设置自定义 header 。理论上我可以像这样在配置脚本中设置一个 - append_hf("X-MyHeader: myvalue\r\n
DTMF 用于一些基于 sip 的软电话来处理负载类型。但是我不清楚使用 DTMF 的过程和重要性。开源软件电话,如 Red5phone和 Sipdroid使用 DTMF。任何人都可以解释这个问题或指
我需要一种在使用 Asterisk 调用文件发起调用时添加 SIP header 的方法。 有什么办法可以在通话文件中添加SIP头吗? 我知道我可以使用 Asterisk AGI 完成此操作,但是我找
我目前在连接到我的 SIP 客户端(IVR 语音服务)的对称 NAT 后面存在 SIP 用户代理问题。 我读到 Asterisk 在 sip.conf 中有一个解决方案,我可以在那里设置属性 nat=
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
我的客户公司有一个简单的 Web 应用程序 (Python Flask),我需要向它添加电话通知功能。 主要要求是应用程序应该调用用户、播放某个声音文件并接受一些音调输入(“您好!这是来自您的 Web
我是一名优秀的程序员,十分优秀!