Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl not giving any data on RESTCONF. #34

Closed
shubhtrix opened this issue Jul 12, 2018 · 11 comments
Closed

curl not giving any data on RESTCONF. #34

shubhtrix opened this issue Jul 12, 2018 · 11 comments

Comments

@shubhtrix
Copy link

Hi @olofhagsand !!!

I'm trying to run RESTCONF on my localhost, but on doing a curl, it is giving 502 Bad Gateway
.Can you figure out, what am I missing on configuring restconf???? Some output for running processes are as follows (for clixon & for nginx)...

AS ROOT : 01:31 PM : yang :) ps aux | grep [c]lixon
root 10189 0.0 0.0 28408 396 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf
root 10470 0.0 0.0 28412 484 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf
root 11228 0.0 0.0 28412 488 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf
root 16151 0.0 0.1 65612 4332 pts/4 S+ 11:26 0:00 sudo su -c /www-data/clixon_restconf -f /usr/local/etc/example.xml -s /bin/sh root
root 16152 0.0 0.1 65140 4036 pts/4 S+ 11:26 0:00 su -c /www-data/clixon_restconf -f /usr/local/etc/example.xml -s /bin/sh root
root 16165 0.0 0.0 4628 808 ? Ss 11:26 0:00 sh -c /www-data/clixon_restconf -f /usr/local/etc/example.xml
root 16166 0.0 0.0 23648 3300 ? S 11:26 0:00 /www-data/clixon_restconf -f /usr/local/etc/example.xml
root 18001 0.0 0.0 30528 3392 pts/1 S+ 12:49 0:00 clixon_backend -Ff /usr/local/etc/example.xml
root 18015 0.0 0.0 24376 3412 pts/2 S+ 12:50 0:00 clixon_netconf -f /usr/local/etc/example.xml
AS ROOT : 01:31 PM : yang :) ps aux | grep [n]ginx
root 16416 0.0 0.0 140656 1504 ? Ss 11:37 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 16417 0.0 0.1 143272 6272 ? S 11:37 0:00 nginx: worker process
www-data 16418 0.0 0.1 143272 6272 ? S 11:37 0:00 nginx: worker process
AS ROOT : 01:31 PM : yang :)
AS ROOT : 01:31 PM : yang :)
AS ROOT : 01:31 PM : yang :) curl -G http://127.0.0.1/restconf/data

<title>502 Bad Gateway</title>

502 Bad Gateway


nginx/1.14.0 (Ubuntu) AS ROOT : 01:33 PM : yang :) AS ROOT : 01:31 PM : yang :) ps aux | grep [c]lixon root 10189 0.0 0.0 28408 396 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf root 10470 0.0 0.0 28412 484 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf root 11228 0.0 0.0 28412 488 pts/0 Ss+ Jul11 0:00 /usr/sbin/clixon_backend -F -f /data/clixon.conf root 16151 0.0 0.1 65612 4332 pts/4 S+ 11:26 0:00 sudo su -c /www-data/clixon_restconf -f /usr/local/etc/example.xml -s /bin/sh root root 16152 0.0 0.1 65140 4036 pts/4 S+ 11:26 0:00 su -c /www-data/clixon_restconf -f /usr/local/etc/example.xml -s /bin/sh root root 16165 0.0 0.0 4628 808 ? Ss 11:26 0:00 sh -c /www-data/clixon_restconf -f /usr/local/etc/example.xml root 16166 0.0 0.0 23648 3300 ? S 11:26 0:00 /www-data/clixon_restconf -f /usr/local/etc/example.xml root 18001 0.0 0.0 30528 3392 pts/1 S+ 12:49 0:00 clixon_backend -Ff /usr/local/etc/example.xml root 18015 0.0 0.0 24376 3412 pts/2 S+ 12:50 0:00 clixon_netconf -f /usr/local/etc/example.xml AS ROOT : 01:31 PM : yang :) ps aux | grep [n]ginx root 16416 0.0 0.0 140656 1504 ? Ss 11:37 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; www-data 16417 0.0 0.1 143272 6272 ? S 11:37 0:00 nginx: worker process www-data 16418 0.0 0.1 143272 6272 ? S 11:37 0:00 nginx: worker process AS ROOT : 01:31 PM : yang :) AS ROOT : 01:31 PM : yang :) AS ROOT : 01:31 PM : yang :) curl -G http://127.0.0.1/restconf/data <title>502 Bad Gateway</title>

502 Bad Gateway


nginx/1.14.0 (Ubuntu) AS ROOT : 01:33 PM : yang :)

Regards,
Shubham

@olofhagsand
Copy link
Member

Bad gateway is (typically) if there is no fastcgi program accessible from nginx, in this case the clixon_restconf daemon.
Ensure the nginx configuration file (/etc/nginx/sites-available/default) looks something like the example in apps/restconf/README.md
And you shouldn't have multiple clixon_backend:s in your ps. Just a single one.

@olofhagsand
Copy link
Member

Can you please supply nginx config file. And exactly how you start backend, restconf and curl command?

@shubhtrix
Copy link
Author

oh ya hi!!!

Thanks a lot, it is working now but some part. Can you help me with this....

AS ROOT : 07:59 PM : restconf :) vim README.md
AS ROOT : 08:00 PM : restconf :) curl -G http://127.0.0.1/restconf
{
"restconf": {
"data": null,
"operations": null,
"yang-library-version": "2016-06-21"
}
}
AS ROOT : 08:00 PM : restconf :) curl -G http://127.0.0.1/restconf/data/interfaces
{
"ietf-restconf:errors" : {
"error": {
"rpc-error": {
"error-tag": "operation-failed",
"error-type": "protocol",
"error-severity": "error",
"error-message": "connecting unix socket: /usr/local/var/example/example.sock.Client should be >member of group $CLICON_SOCK_GROUP: "
}
}
}

}
AS ROOT : 08:00 PM : restconf :)

No multiple restcof's. And Have checked README.md under apps/restconf/. Why restconf is not able to get the data. or Should the question be from where it is reading all that data.

Thanks a lot!!!

Regards,
Shubham

@shubhtrix
Copy link
Author

Oh sorry!!!

My nginx config file is like this

`# Default server configuration

server {
listen 80 default_server;
listen [::]:80 default_server;

location /restconf {
    root /usr/share/nginx/html/restconf;
    fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
    include fastcgi_params;
}

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

# root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name _;

# location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#	try_files $uri $uri/ =404;
# }

# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
#	include snippets/fastcgi-php.conf;
#
#	# With php-fpm (or other unix sockets):
#	fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#	# With php-cgi (or other tcp sockets):
#	fastcgi_pass 127.0.0.1:9000;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#	deny all;
#}

}`

Not able to get the data now that is the only part remaining.

@olofhagsand
Copy link
Member

Seems like you have not setup the clixon group.
https://github.com/clicon/clixon/blob/master/doc/FAQ.md#do-i-need-to-setup-anything

@olofhagsand
Copy link
Member

Also www-data need to be member of that group:
clicon:x:1001:shubhtrix,www-data

@olofhagsand
Copy link
Member

I have updated https://github.com/clicon/clixon/blob/develop/doc/FAQ.md and https://github.com/clicon/clixon/blob/develop/example/README.md to make this clearer.
Please tell me if it still does not work.
The nginx conf looks OK.

@shubhtrix
Copy link
Author

Ya ya !!!
Man i'm on it just a sec.

@shubhtrix
Copy link
Author

Whoa!!!
Hurra :)

AS ROOT : 08:36 PM : doc :) curl -G http://127.0.0.1/restconf/data/
{
"data": {
"interfaces-state": {
"interface": [
{
"name": "eth0",
"type": "ex:eth",
"if-index": 42
}
]
}
}
}

Yo some data came. Ah Thanks a lot so how can I use more manipulation. I know you posted some already at FAQ. But any other suggestions please not the RFC :)

Thanks once again for your so fast responses and help.
Regards,
Shubham

@shubhtrix
Copy link
Author

shubhtrix commented Jul 13, 2018

Hi!!!

And i think this is just state data. i think I'm not getting the configuration data. Is it so??

Regards,
Shubham

@olofhagsand
Copy link
Member

Restconf GET gives a combined configuration and state data resources, it differs form netconf in that way that there is no separate config and state data get method.
There are some more examples in apps/restconf/README.md.
I consider this issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants