Rails 4.x로 업그레이드 한 후 Rails 웹 서비스의 Ruby가 작동하지 않음

coppola_f

얼마 전에 RoR v.3.2.13을 사용하여 웹 애플리케이션을 작성했습니다. 모든 것이 한동안 올바르게 테스트되고 작동했습니다 ... 이제 모든 환경을 rails 4.2.5로 업데이트 할 것입니다! 나는 프레임 워크를 업그레이드하는 데 많은 문제를 발견했고, 웹에서 많은 제안을 찾기 위해 거의 쉽게 해결되었습니다 !!

마지막은 나에게 더 많은 문제를주고있다 ...

음, 일부 데이터베이스 레코드를 업데이트하기 위해 팜 장치에서 서버로 .xml 스트림을 업로드해야합니다 ....

다음은 모바일 터미널이 서버로 보내는 .xml 스트림의 예입니다.

<?xml version="1.0" encoding="utf-8"?>
<readings>
 <reading>
  <opercode>a001a</opercode>
  <barcode>000073680</barcode>
  <opid>4</opid>
  <datetime>2012-01-22T00:07:34+01:00</datetime>
 </reading>
 <reading>
  <opercode>a001a</opercode>
  <barcode>000073679</barcode>
  <opid>4</opid>
  <datetime>2012-01-22T00:07:38+01:00</datetime>
 </reading>
</readings>

보시다시피, 여기에는 각각 4 개의 필드를 포함하는 많은 판독 값이 포함되어 있습니다.

무선 연결이 작동하지 않는 경우 html 양식과 파일 업로드 필드가 포함 된보기를 구축했습니다 ....

컨트롤러는 여기에서 볼 수있는 것과 동일한 작업을 사용하여 스트림을 수신합니다.

.........................
#
# receives the readings stream and passes it to the parser
def upload
  #
  # different part of code if request is from .html o .xml
  respond_to do |format|
    # the request is from .html page
    format.html do
      # checks the uploaded file 'content type'
      if params[:readings_file].instance_variable_get(:@content_type) == "text/xml"
        # the file is .xml
        # identifies the readings operator_id
        operator_id = Operator.find_by_code(params[:readings_file].instance_variable_get(:@original_filename)[0..4]).id
        # retrieves the number of readings stored into .xml file
        original_filename = params[:readings_file].instance_variable_get(:@original_filename).partition(".")[0]
        expected_readings = original_filename.partition("-P-")[2].to_i != 0 ? original_filename.partition("-P-")[2].to_i : original_filename.partition("--")[2].to_i
        # binds the temporary file for nokogiri parsing
        temp_file = File.open(params[:readings_file].instance_variable_get(:@tempfile))
        readings_to_be_loaded = Nokogiri::XML(temp_file)
        # parses the readings records
        result = parse_xml(readings_to_be_loaded, operator_id)
        # checks parsing result against expected readings count
        if result != expected_readings
          message = "WARNING - Inside .xml " + expected_readings.to_s + " records was present, only " + result.to_s + " has been accepted as valid readings!!"
        else
          message = "OK - .xml stream succesfully parsed!"
        end
      else
        # the file is not .xml
        message = "ERROR - Invalid readings file format detected --> 'not xml'!!"
      end
      logger.debug message
      redirect_to readings_path, :flash => {:message => message} and return
    end
    #
    # the request is from .xml stream
    format.xml  do
      if params[:readings].present?
        # determines the number of expected readings inside the stream and retrieves the operator code
        if params[:readings][:reading][0].nil?
          expected_readings = 1
          oper_code = params[:readings][:reading][:opercode]
        else
          expected_readings = params[:readings][:reading].count
          oper_code = params[:readings][:reading][0][:opercode]
        end
        # initializes the good readings counter
        readings_count = 0
        ........

        omissis

        ........
      else
        # the stream don't contains readings, return the http error code 406 -> 'Not Acceptable'
        logger.debug "ERROR - Readings file content is incorrectly formatted!!"
        render nothing: true, status: 406 and return
      end
    end
  end
  # not .xml request nor html upload
  # nothing has been processed, ingores the upload and returns status code 404 -> 'resource not found'
  logger.debug "ERROR - Incorrect data stream content"
  render :nothing => true, status: 404 and return
end
................

그런 다음 데이터 스트림이 html에서 파일로 업로드되었거나 .xml 스트림으로 직접 업로드 된 경우 작업을 구분하십시오.

이제 html보기를 사용하여 파일을 업로드하면 모두 잘 작동합니다 (레일 3.2 또는 4.2 모두 올바르게 작동하고 판독 값을 구문 분석합니다) ....

터미널에서 콘솔을 사용하여 직접 .xml 업로드 작업을 시뮬레이션하려면 다음 명령 줄을 사용합니다.

curl -v -H "Content-Type: application/xml; charset=utf-8" --data-ascii @a001a-12115-81843-P-5.xml http://localhost:3000/readings/upload.xml

스트림이 .xml 형식을 사용하여 직접 업로드되는 경우 ... rails 3.2는 정상적으로 실행되고 rails 4.2는 "406 Not Acceptable"을 반환합니다 (추출 된 로그 행 참조).

레일 3.2에서 로그 :

Started POST "/readings/upload.xml" for 127.0.0.1 at 2015-01-22 21:32:35 +0100
Processing by ReadingsController#upload as XML
  Parameters: {"readings"=>{"reading"=>[{"opercode"=>"a001a", "barcode"=>"000073685", "opid"=>"4", "datetime"=>"2015-01-21T20:18:20+01:00"}, {"opercode"=>"a001a", "barcode"=>"000073683", "opid"=>"4", "datetime"=>"2015-01-21T20:18:24+01:00"}, {"opercode"=>"a001a", "barcode"=>"000073682", "opid"=>"4", "datetime"=>"2015-01-21T20:18:28+01:00"}, {"opercode"=>"a001a", "barcode"=>"000073679", "opid"=>"4", "datetime"=>"2015-01-21T20:18:36+01:00"}, {"opercode"=>"a001a", "barcode"=>"000073683", "opid"=>"4", "datetime"=>"2015-01-21T20:18:41+01:00"}]}}
  Rendered text template (0.0ms)
Completed 200 OK in 49ms (Views: 48.2ms | ActiveRecord: 0.0ms)

레일 4.2에서 로그 :

Started POST "/readings/upload.xml" for 127.0.0.1 at 2016-05-27 21:11:38 +0200
Processing by ReadingsController#upload as XML
ERROR - Readings file content is incorrectly formatted!!
  Rendered text template (0.0ms)
Completed 406 Not Acceptable in 2ms (Views: 0.2ms | ActiveRecord: 0.0ms)

매개 변수가 컨트롤러 동작에 전혀 도달하지 않는 것 같습니다 !! (이것은 4.2 버전의 프레임 워크에 대한 일종의 제한 때문이라고 생각하지만 용의자를 확인하거나 반박하는 특정 정보를 찾을 수 없습니다)

PLS 참고 : 손바닥 장치를 사용하여 직접 스트림을 보내려고하면 동일한 응답을받습니다 !!

어떤 제안도 잘 받아 들여집니다.

미리 감사드립니다. 프란체스코

coppola_f

내가 해결 했어 ...

다시 테스트하고 테스트합니다 .... 이것은 문제가되지 않았습니다 !!

개발 환경에서 레일을 시작할 때 로컬 호스트 주소에서만 수신하므로 외부 장치와의 애플리케이션 상호 작용을 테스트해야하는 경우 명시 적으로 개발자 PC 공용 IP 주소에서 수신하도록해야합니다. ...

여기에 설명 된대로 수행됩니다. Rails 4.2 개발 서버의 기본 바인딩 IP를 변경하는 방법은 무엇입니까?

이제 데이터가 웹 서비스에 도달하고 xml 스트림이 올바르게 처리됩니다!

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Rails 4에서 Rails 5로 업그레이드 한 후 사용자 지정 오류 처리가 더 이상 작동하지 않습니다.

분류에서Dev

Rails 4.2.9로 업그레이드 한 후 Ajax가 작동하지 않습니다 (형식 : : js).

분류에서Dev

GMS 서비스 8.1로 업그레이드 한 후 Play 게임 서비스가 작동하지 않음

분류에서Dev

11.10에서 12.04로 업그레이드 한 후 X가 시작되지 않음

분류에서Dev

11.10에서 12.04로 업그레이드 한 후 X가 시작되지 않음

분류에서Dev

Dell 3521에서 Windows 8.1로 업그레이드 한 후 AMD 그래픽 카드가 작동하지 않음

분류에서Dev

11.10에서 12.04로 업그레이드 한 후 Skype 비디오가 작동하지 않음

분류에서Dev

Django 1.11로 업그레이드 한 후 csrftoken 태그가 작동하지 않음

분류에서Dev

20.04로 업그레이드 한 후 HDMI 사운드가 작동하지 않음

분류에서Dev

16.04에서 18.04로 업그레이드 한 후 Epson GT-S50 스캐너가 작동하지 않음

분류에서Dev

Ubuntu 19.04로 업그레이드 한 후 Lenovo Thinkpad L480에서 터치 패드가 작동하지 않음

분류에서Dev

Ubuntu 19.04로 업그레이드 한 후 Lenovo Thinkpad L480에서 터치 패드가 작동하지 않음

분류에서Dev

11.10에서 14.04로 업그레이드 한 후 랩톱 키보드 키가 작동하지 않음

분류에서Dev

Rails 6.1.0으로 업그레이드 한 후 ActiveStorage :: Blob에 대한 정의되지 않은 메서드 'service_name'

분류에서Dev

Ubuntu 17.04에서 Ubuntu 17.10으로 업그레이드 한 후 이름 바꾸기가 작동하지 않음

분류에서Dev

14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

분류에서Dev

14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

분류에서Dev

14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

분류에서Dev

12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

분류에서Dev

12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

분류에서Dev

13.10으로 업그레이드 한 후 대시가 작동하지 않음

분류에서Dev

Angular 9로 업그레이드 한 후 @ViewChild가 작동하지 않음

분류에서Dev

각도 9로 업그레이드 한 후 ViewChild가 작동하지 않음

분류에서Dev

Windows 10으로 업그레이드 한 후 CD / DVD가 작동하지 않음

분류에서Dev

13.10으로 업그레이드 한 후 대시가 작동하지 않음

분류에서Dev

12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

분류에서Dev

Ubuntu 13.04를 14.04로 업그레이드 한 후 Unity가 작동하지 않음

분류에서Dev

ant 1.9.2로 업그레이드 한 후 Ant Script importPackage가 작동하지 않음

분류에서Dev

Python 3.5.2로 업그레이드 한 후 Python jsonrpclib가 작동하지 않음

Related 관련 기사

  1. 1

    Rails 4에서 Rails 5로 업그레이드 한 후 사용자 지정 오류 처리가 더 이상 작동하지 않습니다.

  2. 2

    Rails 4.2.9로 업그레이드 한 후 Ajax가 작동하지 않습니다 (형식 : : js).

  3. 3

    GMS 서비스 8.1로 업그레이드 한 후 Play 게임 서비스가 작동하지 않음

  4. 4

    11.10에서 12.04로 업그레이드 한 후 X가 시작되지 않음

  5. 5

    11.10에서 12.04로 업그레이드 한 후 X가 시작되지 않음

  6. 6

    Dell 3521에서 Windows 8.1로 업그레이드 한 후 AMD 그래픽 카드가 작동하지 않음

  7. 7

    11.10에서 12.04로 업그레이드 한 후 Skype 비디오가 작동하지 않음

  8. 8

    Django 1.11로 업그레이드 한 후 csrftoken 태그가 작동하지 않음

  9. 9

    20.04로 업그레이드 한 후 HDMI 사운드가 작동하지 않음

  10. 10

    16.04에서 18.04로 업그레이드 한 후 Epson GT-S50 스캐너가 작동하지 않음

  11. 11

    Ubuntu 19.04로 업그레이드 한 후 Lenovo Thinkpad L480에서 터치 패드가 작동하지 않음

  12. 12

    Ubuntu 19.04로 업그레이드 한 후 Lenovo Thinkpad L480에서 터치 패드가 작동하지 않음

  13. 13

    11.10에서 14.04로 업그레이드 한 후 랩톱 키보드 키가 작동하지 않음

  14. 14

    Rails 6.1.0으로 업그레이드 한 후 ActiveStorage :: Blob에 대한 정의되지 않은 메서드 'service_name'

  15. 15

    Ubuntu 17.04에서 Ubuntu 17.10으로 업그레이드 한 후 이름 바꾸기가 작동하지 않음

  16. 16

    14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

  17. 17

    14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

  18. 18

    14.04에서 16.04로 업그레이드 한 후 MySQL이 작동하지 않음

  19. 19

    12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

  20. 20

    12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

  21. 21

    13.10으로 업그레이드 한 후 대시가 작동하지 않음

  22. 22

    Angular 9로 업그레이드 한 후 @ViewChild가 작동하지 않음

  23. 23

    각도 9로 업그레이드 한 후 ViewChild가 작동하지 않음

  24. 24

    Windows 10으로 업그레이드 한 후 CD / DVD가 작동하지 않음

  25. 25

    13.10으로 업그레이드 한 후 대시가 작동하지 않음

  26. 26

    12.04로 업그레이드 한 후 Logitech M515가 작동하지 않음

  27. 27

    Ubuntu 13.04를 14.04로 업그레이드 한 후 Unity가 작동하지 않음

  28. 28

    ant 1.9.2로 업그레이드 한 후 Ant Script importPackage가 작동하지 않음

  29. 29

    Python 3.5.2로 업그레이드 한 후 Python jsonrpclib가 작동하지 않음

뜨겁다태그

보관